/*******************************************************************************
*  Project      : Minigate Golfin                                 
*  Program ID   : date_reserve.js                                 
*  Description  : 실시간 예약 
*
********************************************************************************
*  Program History                                                            
*  Date        Author    Description                                          
*  ----------  --------  -------------------------------------------------------- 
*  2012-05-04  김효순    Created.  
*  2012-05-07  김효순    Complete.  
*******************************************************************************/

jQuery(function($){
	// 좌측 예약분류
	function clsLeftReserveType()
	{
		this._HTMLDom = null;
		this._listData = null;
		
		this._init();
	}
	
	clsLeftReserveType.prototype = {
		_init: function(){
			var $layer = $("div#container section#left_content article.ma_bottom25");
			this._HTMLDom = {
				"$layer": $layer
			}
			
			this._setList([
				"실시간 예약"
				, "웨이팅 예약"
				, "이벤트 부킹"
			]);
		}
		, $getLayer: function(){
			return this._HTMLDom["$layer"];
		}
		, _setList: function(thisData){
			this._listData = thisData;
			this._display();
		}
		, _display: function(){
			var $layer = this.$getLayer();
			var thisClass = this;
			
			$layer.find("select").empty();
			for(var i=0;i<this._listData.length;i++){
				$layer.find("select").append("<option>" + thisClass._listData[i] + "</option>");
			}
		}
		, setIdx: function(idx){
			var $layer = this.$getLayer();
			$layer.find("option").eq(idx).prop("selected", true);
		}
		, getIdx: function(){
			var $layer = this.$getLayer();
			
			return $layer.find("option").index($layer.find("option:selected"));
		}
	}
	
	// 본문 예약분류
	/*function clsBodyReserveType()
	{
		this._HTMLDom = null;
		this._listData = null;
		
		this._init();
	}
	
	clsBodyReserveType.prototype = {
		_init: function(){
			var $layer = $("div#container section#main_content:eq(1) select:eq(2)");
			this._HTMLDom = {
				"$layer": $layer
			}
			
			this._setList([
				{
					"키": "2"
					, "타이틀": "실시간 예약"
				}
				, {
					"키": "3"
					, "타이틀": "웨이팅 예약"
				}
				, {
					"키": "4"
					, "타이틀": "이벤트 부킹"
				}
			]);
			this.setIdx(0);
		}
		, _setList: function(thisData){
			this._listData = thisData;
			this._display();
		}
		, _display: function(){
			var $layer = this._HTMLDom["$layer"];
			var thisClass = this;
			
			$layer.empty();
			for(var i=0;i<this._listData.length;i++){
				$layer.append("<option />");
			}
			$layer.find("option").each(function(n){
				$(this).text(thisClass._listData[n]["타이틀"]);
			});
		}
		, setIdx: function(idx){
			this._HTMLDom["$layer"].find("option").eq(idx).attr("selected", "selected");
		}
		, getIdx: function(){
			var $layer = this._HTMLDom["$layer"];
			
			return $layer.find("option").index($layer.find("option:selected"));
		}
		, getKey: function(){
			var $layer = this._HTMLDom["$layer"];
			var n = $layer.find("option").index($layer.find("option:selected"));
			
			return this._listData[n]["키"];
		}
	}*/
	
	
	// 달력
	function clsCalendar()
	{
		this._HTMLDom = null;
		this.infoData = null;
		
		this._init();
	}
	
	clsCalendar.prototype = {
		_init: function(){
			var $layer = $("div#container section#left_content article.calendar");
			this._HTMLDom = {
				"$layer": $layer
				, "$element": $layer.find("tr:first").clone(true)
			}
			
			this.infoData = {
				"달력일": null
				, "시작일": null
			}
		}
		, setInfo: function(key, val){
			switch(key){
				case "달력일":
					val.setDate(1);
					break;
				case "시작일":
					if(this.infoData["달력일"] && val.getMonth() != this.infoData["달력일"].getMonth()){
						var nDate = new Date();
						nDate.setTime(val.getTime());
						nDate.setDate(1);
						
						this.infoData["달력일"] = nDate;
					}
					break;
			}
			
			this.infoData[key] = val;
			this.display();
		}
		, nextMonth: function(){
			this.infoData["달력일"].setMonth(this.infoData["달력일"].getMonth()+1);
			this.display();
		}
		, prevMonth: function(){
			this.infoData["달력일"].setMonth(this.infoData["달력일"].getMonth()-1);
			this.display();
		}
		, getSDate: function(){
			return this.infoData["시작일"];
		}
		, display: function(){
			if(!(this.infoData["달력일"] &&  this.infoData["시작일"])) return;
			
			var $layer = this._HTMLDom["$layer"];
			var $element = this._HTMLDom["$element"];
			var thisClass = this;
			var dayOfWeek = this.infoData["달력일"].getDay();
			var endDay = new Date(this.infoData["달력일"].getFullYear(), this.infoData["달력일"].getMonth()+1, 0).getDate();
			
			$layer.find("dt:first").contents().eq(0).remove().end().end().prepend((this.infoData["달력일"].getMonth()+1) + "월");
			
			$layer.find("tbody").empty();
			for(var i=1;i-dayOfWeek<=endDay;i+=7){
				$layer.find("tbody").append($element.clone(true));
			}
			
			$layer.find("tbody tr td").each(function(n){
				var thisDay = n-dayOfWeek+1;
				var today = new Date();
				today.setHours(0);
				today.setMinutes(0);
				today.setSeconds(0);
				today.setMilliseconds(0);
				
				$(this).attr("class", "").html("");
				if(thisDay > 0 && thisDay <= endDay){
					var newDate = new Date();
					newDate.setTime(thisClass.infoData["달력일"].getTime());
					newDate.setDate(thisDay);
					
					var endDate = new Date();
					endDate.setTime(thisClass.infoData["시작일"].getTime());
					endDate.setDate(endDate.getDate() + document.objControl.CALENDAR_PERIOD-1);
					
					$(this).html(thisDay).data("날짜", newDate);
					if(newDate.getTime() == today.getTime()) $(this).addClass("today");
					if(newDate.getTime() == thisClass.infoData["시작일"].getTime()) $(this).addClass("start_day");
					if(newDate.getTime() > thisClass.infoData["시작일"].getTime() && newDate.getTime() <= endDate.getTime()) $(this).addClass("res_day");
				}else{
					$(this).data("날짜", null);
				}
			});
		}
		, $getBtnPrev: function(){
			return this._HTMLDom["$layer"].find("span.bt_prev");
		}
		, $getBtnNext: function(){
			return this._HTMLDom["$layer"].find("span.bt_next");
		}
		, $getBtnCalendar: function(){
			return this._HTMLDom["$layer"].find("tbody tr td");
		}
	}
	
	// 지역선택(좌메뉴)
	function clsAreaGolfList()
	{
		this._HTMLDom = null;
		this.listData = null;
		
		this._init();
	}
	
	clsAreaGolfList.prototype = {
		_init: function(){
			var $layer = $("div#container section#left_content article.area_choice dl");
			this._HTMLDom = {
				"$layer": $layer
				, "$element": $layer.find("label:first").clone(true)
			}
			
			//this.setAreaList([]);
			//this.setCourseList([]);
		}
		, setAreaList: function(thisData){
			this.listData = [{
				"코스코드": ""
				, "내용": "전체"
			}].concat(thisData);
		}
		, setGolfList: function(thisData){
			for(var i=0;i<thisData.length;i++){
				for(var j=0;j<this.listData.length;j++){
					if(this.listData[j]["지역코드"] == thisData[i]["지역코드"]) break;
				}
				if(j < this.listData.length){
					if(!this.listData[j]["골프리스트"]) this.listData[j]["골프리스트"] = new Array();
					this.listData[j]["골프리스트"].push(thisData[i]);
				}
			}
			
			this.display();
		}
		, setMyConfig: function(thisData){
			var $layer = this._HTMLDom["$layer"];
			
			for(var i=0;i<thisData.length;i++){
				$layer.find("input:checkbox[value='" + thisData[i]["지역코드"] + "," + thisData[i]["골프장코드"] + "']").attr("checked", "checked");
			}
		}
		, display: function(){
			var $layer = this._HTMLDom["$layer"];
			var $element = this._HTMLDom["$element"];
			var thisClass = this;
			
			$layer.empty();
			for(var i=0;i<this.listData.length;i++){
				var item = this.listData[i];
				var items = item["골프리스트"]
				
				$layer.append("<dt />").find("dt:last").append($element.clone(true));
				
				if(items){
					$layer.append("<dd />");
					for(var j=0;j<items.length;j++){
						$layer.find("dd:last").append($element.clone(true));
					}
					$layer.find("dd:last label").each(function(n){
						$(this).find(":checkbox").val(items[n]["지역코드"] + "," + items[n]["골프장코드"]);
						$(this).contents().eq(1).remove().end().end().append(items[n]["골프장명"]);
					});
				}
			}
			$layer.find("dt label").each(function(n){
				$(this).contents().eq(1).remove().end().end().append(thisClass.listData[n]["내용"]);
			});
		}
		, getValue: function(){
			var $layer = this._HTMLDom["$layer"];
			var szRet = "";
			
			$layer.find(":checkbox:checked").filter(function(){
				if($(this).parent().parent().get(0).tagName.toUpperCase() == "DD") return true;
				else return false;
			}).each(function(){
				if(szRet) szRet += ",";
				szRet += $(this).val();
			});
			
			return szRet;
		}
		, spinStart: function(){
			var $layer = this._HTMLDom["$layer"];
			
			$layer.hide();
			if($layer.parent().find("div#tmpSpin").length == 0){
				$layer.parent().prepend("<div id='tmpSpin' style='position:absolute; width:160px; height:150px;' />");
			}
			$layer.parent().find("div#tmpSpin").show().spin();
		}
		, spinEnd: function(){
			var $layer = this._HTMLDom["$layer"];
			
			$layer.parent().find("div#tmpSpin").hide().spin(false);
			$layer.show();
		}
		, $getCheckBoxs: function(){
			return this._HTMLDom["$layer"].find("input:checkbox");
		}
		, onCheck: function($obj){
			var $layer = this._HTMLDom["$layer"];
			
			var n = this.$getCheckBoxs().index($obj);
			var bCheck = $obj.is(":checked");
			
			if(n == 0){
				this.$getCheckBoxs().filter(":gt(0)").attr("checked", bCheck);
				return;
			}
			
			var $parent = $obj.parent().parent();
			
			switch($parent.get(0).tagName.toUpperCase()){
				case "DT":
					$parent.next("dd").find(":checkbox").attr("checked", bCheck);
					break;
				case "DD":
					$parent.prev("dt").find(":checkbox").attr("checked", ($parent.find(":checkbox").length == $parent.find("input:checked").length));
					break;
			}
			
			this.$getCheckBoxs().eq(0).attr("checked", (this.$getCheckBoxs().filter(":gt(0)").length <= this.$getCheckBoxs().filter(":checked").length));
		}
		, $getLayer: function(){
			return this._HTMLDom["$layer"];
		}
	}
	
	// my설정
	function clsMyConfig()
	{
		this._HTMLDom = null;
		this.szData = null;
		
		this._init();
	}
	
	clsMyConfig.prototype = {
		_init: function(){
			$layer = $("div#container section#main_content:eq(0) div.my_set");
			this._HTMLDom = {
				"$layer": $layer
			}
			
			$layer.find("div.box_txt").hide();
			this.setData("");
		}
		, setData: function(szData){
			this.szData = szData;
			this.display();
		}
		, display: function(){
			var $layer = this._HTMLDom["$layer"];
			
			$layer.find("dl:first dd:first").html(this.szData);
		}
		, $getBtnHelp: function(){
			return this._HTMLDom["$layer"].find("dt:first a");
		}
		, toggle: function(){
			var $layer = this._HTMLDom["$layer"];
			
			$layer.find("div.box_txt").toggle();
		}
	}
	
	// 나의 예약내역 확인
	function clsMyReserveListConfirm()
	{
		this._HTMLDom = null;
		this.dataInfo = null;
		
		this._init();
	}
	
	clsMyReserveListConfirm.prototype = {
		_init: function(){
			$layer = $("div#container section#left_content div.reserv_bt");
			this._HTMLDom = {
				"$layer": $layer
			}
			
			this.setInfo(0);
		}
		, setInfo: function(thisData){
			if(!this.dataInfo) this.dataInfo = {};
			
			this.dataInfo["카운트"] = thisData;
			this.display();
		}
		, display: function(){
			var $layer = this._HTMLDom["$layer"];
			
			$layer.find("span").html("(" + this.dataInfo["카운트"] + ")");
		}
		, $getBtn: function(){
			return this._HTMLDom["$layer"];
		}
	}
	
	// 2주력
	function clsWeekCalendar()
	{
		this._HTMLDom = null;
		this.sDate = null;
		this.selDate = null;
		
		this._init();
	}
	
	clsWeekCalendar.prototype = {
		_init: function(){
			var $layer = $("div#container section#main_content:eq(0) article.reserve_area:first thead");
			this._HTMLDom = {
				"$layer": $layer
			}
			
			//$layer.addClass("z_pos");
			
			var thisClass = this;
			this.$getDateBox().css("cursor", "pointer");
		}
		, setDate: function(newDate){
			this.sDate = newDate;
			this.display();
		}
		, setSelDate: function(newDate){
			this.selDate = newDate;
			this.display();
		}
		, display: function(){
			var $layer = this._HTMLDom["$layer"];
			var thisClass = this;
			var aWeekday = ["일", "월", "화", "수", "목", "금", "토"];
			
			$layer.find("th:gt(1)").filter("th:not(.th_next)").css("cursor", "pointer").each(function(n){
				var newDate = new Date();
				newDate.setTime(thisClass.sDate.getTime());
				newDate.setDate(newDate.getDate() + n);
				
				$(this).data("date", newDate);
				$(this).find("p:eq(0)").html(aWeekday[newDate.getDay()]);
				$(this).find("p:eq(1)").html(newDate.getDate());
				
				$(this).attr("class", "");
				
				switch(newDate.getDay()){
					case 0:
						$(this).addClass("holiday");
						break;
					case 6:
						$(this).addClass("satday");
						break;
				}
				
				if(thisClass.selDate && newDate.getTime() == thisClass.selDate.getTime()) $(this).addClass("day_over");
			});
			
			// 두번째 2주력 생성을 위해
			$(this).trigger("evtFinishDisplay", [$layer.find("tr").clone(true)]);
		}
		, getDate: function(){
			return this.sDate;
		}
		, getSelDate: function(){
			return this.selDate;
		}
		, $getBtnPrev: function(){
			return this._HTMLDom["$layer"].find("th.th_prev");
		}
		, $getBtnNext: function(){
			return this._HTMLDom["$layer"].find("th.th_next");
		}
		, $getDateBox: function(){
			return this._HTMLDom["$layer"].find("th:gt(1)").filter("th:not(.th_next)")
		}
		, getSatIndexs: function(){
			var $layer = this._HTMLDom["$layer"];
			var $sat = $layer.find("th").filter(function(){
				return $(this).hasClass("satday");
			});
			
			return [$layer.find("th:gt(1)").index($sat.eq(0)), $layer.find("th:gt(1)").index($sat.eq(1))];
		}
		, getSunIndexs: function(){
			var $layer = this._HTMLDom["$layer"];
			var $sun = $layer.find("th").filter(function(){
				return $(this).hasClass("holiday");
			});
			
			return [$layer.find("th:gt(1)").index($sun.eq(0)), $layer.find("th:gt(1)").index($sun.eq(1))];
		}
		, disable: function(){
			this._HTMLDom["$layer"].parents("article.reserve_area").hide();
		}
		, enable: function(){
			this._HTMLDom["$layer"].parents("article.reserve_area").show();
		}
	}
	
	// 날짜별 코스리스트
	function clsCourseTimeList()
	{
		this._HTMLDom = null;
		this.listData = null;
		this.satIndexs = null;
		this.sunIndexs = null;
		this.listType = null;
		
		this._init();
	}
	
	clsCourseTimeList.prototype = {
		_init: function(){
			var $layer = $("div#container section#main_content:eq(0) article.reserve_area:first tbody");
			this._HTMLDom = {
				"$layer": $layer
				, "$areaElement": $layer.find("tr:first").clone(true)
				, "$element": $layer.find("tr:eq(1)").clone(true)
			}
			
			this.setList([]);
		}
		, setList: function(areaData){
			this.listData = areaData;
		}
		, setCourseList: function(courseData){
			for(var i=0;i<this.listData.length;i++){
				this.listData[i]["코스리스트"] = new Array();
			}
			
			for(var i=0;i<courseData.length;i++){
				for(var j=0;j<this.listData.length;j++){
					if(this.listData[j]["지역코드"]+"" == courseData[i]["지역코드"]+"") break;
				}
				if(j < this.listData.length){
					this.listData[j]["코스리스트"].push(courseData[i]);
				}
			}
			
			this.display();
		}
		, setListType: function(listType){
			this.listType = listType;
		}
		, setSatIndexs: function(idxs){
			this.satIndexs = idxs;
		}
		, setSunIndexs: function(idxs){
			this.sunIndexs = idxs;
		}
		, display: function(){
			var $layer = this._HTMLDom["$layer"];
			var $areaElement = this._HTMLDom["$areaElement"];
			var $element = this._HTMLDom["$element"];
			var thisClass = this;
			
			$layer.empty();
			for(var i=0;i<this.listData.length;i++){
				var item1 = this.listData[i];
				
				$layer.append($areaElement.clone(true));
				
				if(item1["코스리스트"].length > 0){
					for(j=0;j<item1["코스리스트"].length;j++){
						var item2 = item1["코스리스트"][j];
						
						$layer.append($element.clone(true));
						$layer.find("tr:last td:not(:last)").each(function(n){
							var item3 = item2[n-1];
							
							if(n == 0){
								$(this).html(item2["골프장명"] + " " + item2["코스명"]);
							}else{
								$(this).attr("class", "");
								
								switch(thisClass.listType){
									case "실시간": 
										$(this).html("<p class='am'>" + item2["리스트"][n-1]["오전"] + "</p> <p class='pm'>" + item2["리스트"][n-1]["오후"] + "</p>");
										break;
									case "웨이팅": 
										$(this).html((item2["리스트"][n-1]["가능여부"]) ? '<img src="../images/btn/btn_waiting.png" alt="waiting">':"");
										break;
								}
							}
						});
					}
				}
			}
			
			$layer.find("tr td.area_c").each(function(n){
				$(this).html("[" + thisClass.listData[n]["지역명"] + "]");
			});
			
			$layer.find("tr").has("td:not(.area_c)").find("td:nth-child(" + (this.satIndexs[0]+2) + ")").addClass("satday");
			$layer.find("tr").has("td:not(.area_c)").find("td:nth-child(" + (this.satIndexs[1]+2) + ")").addClass("satday");
			
			$layer.find("tr").has("td:not(.area_c)").find("td:nth-child(" + (this.sunIndexs[0]+2) + ")").addClass("holiday");
			$layer.find("tr").has("td:not(.area_c)").find("td:nth-child(" + (this.sunIndexs[1]+2) + ")").addClass("holiday");
		}
		, spinStart: function(){
			var $layer = this._HTMLDom["$layer"];
			
			$layer.hide();
			if($layer.parent().parent().find("div#tmpSpin").length == 0){
				$layer.parent().parent().append("<div id='tmpSpin' style='position:relative; width:700px; height:100px;' />");
			}
			$layer.parent().parent().find("div#tmpSpin").show().spin();
		}
		, spinEnd: function(){
			var $layer = this._HTMLDom["$layer"];
			
			$layer.parent().parent().find("div#tmpSpin").hide().spin(false);
			$layer.show();
		}
		, $getLayer: function(){
			return this._HTMLDom["$layer"];
		}
		, $getBtns: function(){
			return this._HTMLDom["$layer"].find("tr td:not(.area_c):not(.td_cor):not(.td_bl)");
		}
		, getAreaKey: function(n){
			for(var i=0;i<this.listData.length;i++){
				var listLen = this.listData[i]["코스리스트"].length;
				
				if(listLen - n < 0){
					n -= listLen;
				}else{
					break;
				}
			}
			
			if(i<this.listData.length){
				return this.listData[i]["지역코드"];
			}else{
				return null;
			}
		}
		, getCourseKey: function(n){
			for(var i=0;i<this.listData.length;i++){
				var listLen = this.listData[i]["코스리스트"].length;
				
				if(listLen - n < 0){
					n -= listLen;
				}else{
					break;
				}
			}
			
			if(i<this.listData.length){
				return this.listData[i]["코스리스트"][n]["코스코드"];
			}else{
				return null;
			}
		}
	}
	
	
	// 지역선택
	function clsAreaList()
	{
		this._HTMLDom = null;
		this.listData = null;
		
		this._init();
	}
	
	clsAreaList.prototype = {
		_init: function(){
			var $layer = $("div#container section#main_content:eq(1) div.area_search select:eq(0)");
			this._HTMLDom = {
				"$layer": $layer
			}
			
			this.setList([]);
			this.setIdx(0);
		}
		, setList: function(thisData){
			this.listData = [{
				"지역코드": ""
				, "지역명": "지역 선택"
			}].concat(thisData);
			this.display();
		}
		, display: function(){
			var $layer = this._HTMLDom["$layer"];
			var thisClass = this;
			
			$layer.empty();
			for(var i=0;i<this.listData.length;i++){
				$layer.append("<option />");
			}
			$layer.find("option").each(function(n){
				$(this).text(thisClass.listData[n]["지역명"]);
			});
		}
		, setIdx: function(idx){
			this._HTMLDom["$layer"].find("option").eq(idx).attr("selected", "selected");
		}
		, setKey: function(key){
			for(var i=0;i<this.listData.length;i++){
				if(key == this.listData[i]["지역코드"]) break;
			}
			
			if(i<this.listData.length) this.setIdx(i);
		}
		, getValue: function(){
			var $layer = this._HTMLDom["$layer"];
			var n = $layer.find("option").index($layer.find("option:selected"));
			
			return this.listData[n]["지역코드"];
		}
		, $getSelect: function(){
			return this._HTMLDom["$layer"];
		}
	}
	
	
	// 2주력 리스트용
	function clsWeekCalendar2()
	{
		this._HTMLDom = null;
		this.sDate = null
		
		this._init();
	}
	
	clsWeekCalendar2.prototype = {
		_init: function(){
			var $layer = $("div#container section#main_content:eq(1) article.day_ch thead");
			this._HTMLDom = {
				"$layer": $layer
			}
			$layer.find("th:gt(0)").remove();
		}
		, display: function($obj, month){
			var $layer = this._HTMLDom["$layer"];
			
			$layer.find("th:gt(0)").remove();
			$layer.find("tr").append($obj.find("th:gt(0)"));
			
			$layer.find("th:eq(0)").html(month + "월");
		}
		, $getDateBox: function(){
			return this._HTMLDom["$layer"].find("th:gt(1)").filter("th:not(.th_next)");
		}
	}
	
	// 골프장 선택
	function clsCourseList()
	{
		this._HTMLDom = null;
		this.listData = null;
		
		this._init();
	}
	
	clsCourseList.prototype = {
		_init: function(){
			var $layer = $("div#container section#main_content:eq(1) div.area_search select:eq(1)");
			this._HTMLDom = {
				"$layer": $layer
			}
			
			this.reset();
		}
		, reset: function(){
			this.setList([]);
			this.setIdx(0);
		}
		, setList: function(thisData){
			this.listData = [{
				"골프장코드": ""
				, "골프장명": "골프장"
				, "코스코드": ""
				, "코스명": "코스 선택"
			}].concat(thisData);
			this.display();
		}
		, display: function(){
			var $layer = this._HTMLDom["$layer"];
			var thisClass = this;
			
			$layer.empty();
			for(var i=0;i<this.listData.length;i++){
				$layer.append("<option />");
			}
			$layer.find("option").each(function(n){
				$(this).text(thisClass.listData[n]["골프장명"] + "-" + thisClass.listData[n]["코스명"]);
			});
		}
		, setIdx: function(idx){
			this._HTMLDom["$layer"].find("option").eq(idx).attr("selected", "selected");
		}
		, getGolfKey: function(){
			var $layer = this._HTMLDom["$layer"];
			var n = $layer.find("option").index($layer.find("option:selected"));
			
			return this.listData[n]["골프장코드"];
		}
		, setCourseKey: function(key){
			for(var i=0;i<this.listData.length;i++){
				if(key == this.listData[i]["코스코드"]) break;
			}
			
			if(i<this.listData.length) this.setIdx(i);
		}
		, getCourseKey: function(){
			var $layer = this._HTMLDom["$layer"];
			var n = $layer.find("option").index($layer.find("option:selected"));
			
			return this.listData[n]["코스코드"];
		}
	}
	
	
	// 예약리스트
	function clsReserveList()
	{
		this._HTMLDom = null;
		this.listData = null;
		this.orderIdx = null;
		this.idx = null;
		this.typeIdx = null;
		
		this._init();
	}
	
	clsReserveList.prototype = {
		_init: function(){
			var $layer = $("div#container section#main_content:eq(1) article.reserve_list tbody");
			this._HTMLDom = {
				"$layer": $layer
				, "$element0": $layer.eq(0).find("tr:first").clone(true)
				, "$element1": $layer.eq(1).find("tr:first").clone(true)
				, "$btnApply": $layer.eq(1).find("a").has("img[alt='웨이팅신청']").eq(0).clone(true)
				, "$btnCancel": $layer.eq(1).find("a").has("img[alt='신청취소']").eq(0).clone(true)
				, "$btnConfirm": $layer.eq(1).find("a").has("img[alt='예약확정']").eq(0).clone(true)
			}
			
			this.orderIdx = 1;
			this.setType(0);
			this.setList([]);
		}
		, $getLayer: function(){
			return this._HTMLDom["$layer"];
		}
		, setList: function(thisData){
			this.listData = thisData;
			this.idx = null;
			this.display();
		}
		, display: function(){
			var $layer = this._HTMLDom["$layer"].eq(this.typeIdx);
			var $element = this._HTMLDom["$element" + this.typeIdx];
			var thisClass = this;
			
			$layer.empty();
			for(var i=0;i<this.listData.length;i++){
				$layer.append($element.clone(true));
			}
			
			
			/*thisClass.waitingReserveList.push({
							"골프장코드": _util.nvl(obj["golfClubId"])
							, "골프장명": _util.nvl(obj["golfClubNm"])
							, "코스코드": _util.nvl(obj["courseInfoId"])
							, "코스명": _util.nvl(obj["courseInfoNm"])
							, "예약시간": _util.nvl(obj["reservTime"])
							, "홀명": _util.nvl(obj["holeCnt"])
							, "가격": _util.nvl(obj["maxGreenFee "], _util.nvl(obj["maxGreenFee "], 0))
							, "원가": _util.nvl(obj["maxGreenFee "], 0)
							, "내상태코드": _util.nvl(obj["reservStatus"])
							, "내상태": myState[_util.nvl(obj["reservStatus"])]
						});*/
			
			
			
			$layer.find("tr").each(function(n){
				$(this).attr("class", "");
				
				$(this).find("td:eq(0)").html(thisClass.listData[n]["지역명"]);
				$(this).find("td:eq(1)").html(thisClass.listData[n]["골프장명"] + " " + thisClass.listData[n]["코스명"]);
				$(this).find("td:eq(2)").html(thisClass.listData[n]["예약시간"]);
				$(this).find("td:eq(3)").html(thisClass.listData[n]["홀명"]);
				$(this).find("td:eq(4) p:eq(0)").html(thisClass.listData[n]["가격"]);
				$(this).find("td:eq(4) p:eq(1)").html(thisClass.listData[n]["원가"]).show();
				
				if(thisClass.listData[n]["가격"] == thisClass.listData[n]["원가"]) $(this).find("td:eq(4) p:eq(1)").hide();
				
				switch(thisClass.typeIdx+""){
					case "0" :
						$(this).find("td:eq(5)").find("li").each(function(i){
							if(thisClass.listData[n]["이벤트"].indexOf($(this).find("img").attr("alt")) == -1) $(this).html("");
						});
						break;
					case "1": 
						$(this).find("td:eq(5)").html(thisClass.listData[n]["신청대기"] + " <span>명</span>");
						$(this).find("td:eq(6)").html(thisClass.listData[n]["내상태"]);
						switch(thisClass.listData[n]["내상태코드"]){
							case "W001":
								$(this).find("td:eq(6)").textWrap(thisClass.listData[n]["내상태"], "<span />");
								var $btn = thisClass._HTMLDom["$btnCancel"].clone(true);
								break;
							case "W002":
								$(this).find("td:eq(6)").textWrap(thisClass.listData[n]["내상태"], "<em />");
								var $btn = thisClass._HTMLDom["$btnConfirm"].clone(true);
								break;
							default :
								var $btn = thisClass._HTMLDom["$btnApply"].clone(true);
								break;
						}
						$(this).find("td:eq(7)").html($btn);
				}
				
			}).hover(function(){
				$(this).addClass("tr_on");
			}
			, function(){
				$(this).removeClass("tr_on");
			});
			
			this.displayOrder();
		}
		, displayOrder: function(){
			this.$getBtnOrder().find("span").attr("class", "");
			this.$getBtnOrder().eq(this.orderIdx).find("span").addClass("th_t");
		}
		, spinStart: function(){
			var $layer = this._HTMLDom["$layer"].eq(this.typeIdx);
			
			$layer.hide();
			if($layer.parents("article.reserve_list").find("div#tmpSpin").length == 0){
				$layer.parents("article.reserve_list").append("<div id='tmpSpin' style='position:absolute; width:700px; height:100px;' />");
			}
			$layer.parents("article.reserve_list").find("div#tmpSpin").show().spin();
		}
		, spinEnd: function(){
			var $layer = this._HTMLDom["$layer"].eq(this.typeIdx);
			
			$layer.parents("article.reserve_list").find("div#tmpSpin").hide().spin(false);
			$layer.show();
		}
		, $getBtnOrder: function(){
			return this._HTMLDom["$layer"].eq(this.typeIdx).prev("thead").find("th");
		}
		, setOrder: function(idx){
			this.orderIdx = idx;
			this.displayOrder();
		}
		, getOrder: function(){
			return this.orderIdx;
		}
		, getCourseKey: function(){
			if(this.idx == null) return null;
			else return this.listData[this.idx]["코스코드"];
		}
		, getKey: function(){
			if(this.idx == null) return null;
			else return this.listData[this.idx]["예약코드"];
		}
		, getAreaKey: function(){
			if(this.idx == null) return null;
			else return this.listData[this.idx]["지역코드"];
		}
		, getGolfKey: function(){
			if(this.idx == null) return null;
			else return this.listData[this.idx]["골프장코드"];
		}
		, setKey: function(key){
			for(var i=0;i<this.listData.length;i++){
				if(this.listData[i]["키"] == key) break;
			}
			if(i<this.listData.length) this.idx = i;
		}
		, $getBtnCourses: function(bCurrent){
			var $layer = this._HTMLDom["$layer"];
			if(bCurrent) $layer = $layer.eq(this.typeIdx);
			
			return $layer.find("tr td:nth-child(2)");
		}
		, $getBtnApplys: function(){
			return this._HTMLDom["$layer"].find("img[alt='예약신청']");
		}
		, setIdx: function(idx){
			this.idx = idx;
		}
		, setType: function(idx){
			this._HTMLDom["$layer"].parents("article.reserve_list").hide();
			this.typeIdx = idx;
			this._HTMLDom["$layer"].eq(this.typeIdx).parents("article.reserve_list").show();
		}
		, getReserveTime: function(){
			if(this.idx == null) return null;
			else return this.listData[this.idx]["시간대"];
		}
		, getGolfName: function(){
			if(this.idx == null) return null;
			else return this.listData[this.idx]["골프장명"];
		}
		, getCourseName: function(){
			if(this.idx == null) return null;
			else return this.listData[this.idx]["코스명"];
		}
	}
	
	
	// 예약정보
	function clsReserveInfo()
	{
		this._HTMLDom = null;
		this.infoData = null;
		
		this._init();
	}
	
	clsReserveInfo.prototype = {
		_init: function(){
			var $layer = $("div#container section#main_content:eq(2) article.reserve_view_bgc");

			this._HTMLDom = {
				"$layer": $layer
				, "$element": $layer.find("aside.right_view ul.r_event_list li:first").clone(true)
			}
			
			this.setInfo({
				"이벤트리스트": []
			});
		}
		, setInfo: function(thisData){
			this.infoData = thisData;
			this.display();
		}
		, display: function(){
			var $layer = this._HTMLDom["$layer"];
			var $element = this._HTMLDom["$element"];
			var thisClass = this;
			
			$layer.find("p.golf_d span:eq(0)").html(this.infoData["골프장명"] + " " + this.infoData["코스명"]);
			$layer.find("p.golf_d span:eq(1)").html(this.infoData["홀명"]);
			$layer.find("p.res_date").contents().eq(0).before(this.infoData["날짜"] + ". " + this.infoData["요일"] + "요일").remove();
			$layer.find("p.res_date span").html(this.infoData["시간"]);
			$layer.find("div.res_price div.cost span").html(this.infoData["원가"]);
			$layer.find("div.res_price div.sale p.s_price span").html(this.infoData["가격"]);
			$layer.find("p.amount strong.ft_b").html(this.infoData["보증결제금액"] ? this.infoData["보증결제금액"]:"");
			
			$layer.find("ul.ico_list li").each(function(n){
				if(thisClass.infoData["이벤트"] != null){
					if(thisClass.infoData["이벤트"].indexOf($(this).find("img").attr("alt")) == -1) $(this).find("img").hide();
					else $(this).find("img").show();
				}
			});
			
			$layer.find("aside.right_view ul.r_event_list").empty();
			for(var i=0;i<this.infoData["이벤트리스트"].length;i++){
				$layer.find("aside.right_view ul.r_event_list").append($element.clone(true));
			}
			$layer.find("aside.right_view ul.r_event_list li").each(function(n){
				$(this).html(thisClass.infoData["이벤트리스트"][n]);
			});
		}
		, spinStart: function(){
			var $layer = this._HTMLDom["$layer"];
			
			$layer.find("div.reserve_view").children().hide();
			if($layer.find("div.reserve_view div#tmpSpin").length == 0){
				$layer.find("div.reserve_view").append("<div id='tmpSpin' style='position:relative; width:700px; height:150px;' />");
			}
			$layer.find("div.reserve_view div#tmpSpin").show().spin();
		}
		, spinEnd: function(){
			var $layer = this._HTMLDom["$layer"];
			
			$layer.find("div.reserve_view").children().show();
			$layer.find("div.reserve_view div#tmpSpin").hide().spin(false);
		}
		, clone: function(){
			return this._HTMLDom["$layer"].clone(true);
		}
		, getPDate: function(){
			return this.infoData["가승인결제마감일"];
		}
	}
	
	// 예약완료 예약정보
	function clsAbstractReserveInfo()
	{
		this._HTMLDom = null;
		
		this._init();
	}
	
	clsAbstractReserveInfo.prototype = {
		_init: function(){
			var $parent = $("div#container section#main_content:eq(3)");
			this._HTMLDom = {
				"$parent": $parent
				, "$layer": $parent.find("article.reserve_view_bgc")
			}
		}
		, $getLayer: function(){
			return this._HTMLDom["$parent"];
		}
		, setLayer: function($layer){
			var $parent = this._HTMLDom["$parent"];
			
			this._HTMLDom["$layer"].before($layer).remove();
			this._HTMLDom["$layer"] = $layer;
		}
		, spinStart: function(){
			var $layer = this._HTMLDom["$layer"];
			
			$layer.find("div.reserve_view").children().hide();
			if($layer.find("div.reserve_view div#tmpSpin").length == 0){
				$layer.find("div.reserve_view").append("<div id='tmpSpin' style='position:relative; width:700px; height:150px;' />");
			}
			$layer.find("div.reserve_view div#tmpSpin").show().spin();
		}
		, spinEnd: function(){
			var $layer = this._HTMLDom["$layer"];
			
			$layer.find("div.reserve_view div#tmpSpin").hide().spin(false);
			$layer.find("div.reserve_view").children(":not(div#tmpSpin)").show();
		}
		, setPDate: function(pDate){
			var $layer = this._HTMLDom["$parent"];
			
			$layer.find("p.reserve_txt02").html("<em>보증결제 마감일</em>은 <em>" + pDate.getFullYear()+ "년</em> <strong><font class='ft_r'>" + (pDate.getMonth()+1) + "</font>월 <font class='ft_r'>" + pDate.getDate() + "</font>일</strong> 입니다.");
		}
	}
	
	// 예약정보 탭
	function clsReserveInfoTab()
	{
		this.idx = null;
		
		this._init();
	}
	
	clsReserveInfoTab.prototype = {
		_init: function(){
			var $layer = $("div#container section#main_content:eq(2) div.tabmenu");
			this._HTMLDom = {
				"$layer": $layer
			}
			
			$layer.find("li").removeClass("on");
		}
		, setIdx: function(idx){
			this.idx = idx;
			this.display();
		}
		, getIdx: function(){
			return this.idx;
		}
		, display: function(){
			this._HTMLDom["$layer"].find("li").removeClass("on").eq(this.idx).addClass("on");
		}
		, $getLayer: function(){
			return this._HTMLDom["$layer"];
		}
	}
	
	
	// 코스정보
	function clsCourseInfo()
	{
		this._HTMLDom = null;
		this.infoData = null;
		
		this._init();
	}
	
	clsCourseInfo.prototype = {
		_init: function(){
			var $layer = $("div#container section#main_content:eq(2) article.reserve_detail:eq(0)");
			this._HTMLDom = {
				"$layer": $layer
			}
			
			this.setInfo({
				"코스알림": ""
				, "코스명": ""
				, "자세히url": ""
				, "상세정보": ""
			});
		}
		, setInfo: function(thisData){
			this.infoData = thisData;
			this.display();
		}
		, display: function(){
			var $layer = this._HTMLDom["$layer"];
			
			$layer.find("div.detail_info:eq(0)").html(this.infoData["코스알림"]);
			
			var $tmp = $layer.find("div.detail_info:eq(1)").children().clone(true);
			$layer.find("div.detail_info:eq(1)").html(this.infoData["코스명"]).append($tmp);
			if(this.infoData["자세히url"]){
				$layer.find("img[alt='코스자세히보기']").parent("a").attr({
					"target": "_blank"
					, "href": this.infoData["자세히url"]
				}).parent("span.bt_detail").show();
			}
			else{
				$layer.find("img[alt='코스자세히보기']").parents("span.bt_detail").hide();
			}
			
			$layer.find("div.detail_info:eq(1) div.detail_golf").html(this.infoData["상세정보"]);
			
			/*$layer.find("div.detail_info:eq(1) div.detail_golf p:eq(0)").contents().filter(function(){
				return this.nodeType==3;
			}).remove().end().end().append(this.infoData["코스전장"]);
			
			$layer.find("div.detail_info:eq(1) div.detail_golf").find("img").remove().end().append("<img src='" + this.infoData["코스정보이미지"] + "' />");
			
			
			$layer.find("div.detail_golf:eq(0)").contents().filter(function(){
				if(this.nodeType == 3 && this.data.trim()){return true;}
				else return false;
			}).before(this.infoData["골프장정보"]).remove();
			$layer.find("div.detail_info:eq(2) tbody tr:eq(0) td:eq(2)").html(this.infoData["주중회원"]);
			$layer.find("div.detail_info:eq(2) tbody tr:eq(0) td:eq(3)").html(this.infoData["주말회원"]);
			$layer.find("div.detail_info:eq(2) tbody tr:eq(1) td:eq(1)").html(this.infoData["주중비회원"]);
			$layer.find("div.detail_info:eq(2) tbody tr:eq(1) td:eq(2)").html(this.infoData["주말비회원"]);
			$layer.find("div.detail_info:eq(2) tbody tr:eq(2) td:eq(1)").html(this.infoData["주중주중회원"]);
			$layer.find("div.detail_info:eq(2) tbody tr:eq(2) td:eq(2)").html(this.infoData["주말주중회원"]);
			$layer.find("div.detail_info:eq(2) tbody tr:eq(3) td:eq(1)").html(this.infoData["기타가격"]);
			$layer.find("ul.item_info li:eq(0) div.item_cont").html(this.infoData["카트비"]);
			$layer.find("ul.item_info li:eq(1) div.item_cont").html(this.infoData["캐디비"]);
			$layer.find("ul.item_info li:eq(2) div.item_cont").html(this.infoData["대여채비"]);
			$layer.find("ul.item_info li:eq(3) div.item_cont").html(this.infoData["대여화"]);
			$layer.find("ul.item_info li:eq(4) div.item_cont").html(this.infoData["코스인원제한"]);
			$layer.find("div.detail_info:eq(3)").html(this.infoData["패널티정보"]);*/
		}
		, show: function(){
			this._HTMLDom["$layer"].show(300);
		}
		, hide: function(){
			this._HTMLDom["$layer"].hide(300);
		}
		, spinStart: function(){
			var $layer = this._HTMLDom["$layer"];
			
			$layer.children().hide();
			if($layer.find("div#tmpSpin").length == 0){
				$layer.append("<div id='tmpSpin' style='position:relative; width:700px; height:150px;' />");
			}
			$layer.find("div#tmpSpin").show().spin();
		}
		, spinEnd: function(){
			var $layer = this._HTMLDom["$layer"];
			
			$layer.find("div#tmpSpin").hide().spin(false);
			$layer.children(":not(div#tmpSpin)").show();
		}
	}
	
	// 가격정보
	function clsPriceInfo()
	{
		this._HTMLDom = null;
		this.infoData = null;
		
		this._init();
	}
	
	clsPriceInfo.prototype = {
		_init: function(){
			var $layer = $("div#container section#main_content:eq(2) article.reserve_detail:eq(1)");
			this._HTMLDom = {
				"$layer": $layer
			}
			
			this.setInfo({
				"그린피주중회원": 0
				, "그린피주말회원": 0
				, "그린피주중비회원": 0
				, "그린피주말비회원": 0
				, "그린피주중주중회원": 0
				, "그린피주말주중회원": 0
				, "그린피기타": 0
				, "카트비": 0
				, "캐디비": "0 원"
				, "대여채비": 0
				, "대여화": 0
				, "코스인원제한": ""
			});
		}
		, setInfo:clsCourseInfo.prototype.setInfo
		, display: function(){
			var $layer = this._HTMLDom["$layer"];
			
			$layer.find("tbody tr:eq(0) td:eq(1) em").html(this.infoData["그린피주중회원"]);
			$layer.find("tbody tr:eq(0) td:eq(2) em").html(this.infoData["그린피주말회원"]);
			$layer.find("tbody tr:eq(1) td:eq(1) em").html(this.infoData["그린피주중비회원"]);
			$layer.find("tbody tr:eq(1) td:eq(2) em").html(this.infoData["그린피주말비회원"]);
			$layer.find("tbody tr:eq(2) td:eq(1) em").html(this.infoData["그린피주중주중회원"]);
			$layer.find("tbody tr:eq(2) td:eq(2) em").html(this.infoData["그린피주말주중회원"]);
			$layer.find("tbody tr:eq(3) em").html(this.infoData["그린피기타"]);
			$layer.find("tbody tr:eq(4) td").html(this.infoData["카트비"] + " 원");
			$layer.find("tbody tr:eq(5) td").html(this.infoData["캐디비"]);
			$layer.find("tbody tr:eq(6) td").html(this.infoData["대여채비"] + " 원");
			$layer.find("tbody tr:eq(7) td").html(this.infoData["대여화"] + " 원");
			$layer.find("tbody tr:eq(8) td").html(this.infoData["코스인원제한"]);
		}
		, show: clsCourseInfo.prototype.show
		, hide: clsCourseInfo.prototype.hide
		, spinStart: clsCourseInfo.prototype.spinStart
		, spinEnd: clsCourseInfo.prototype.spinEnd
		
	}
	
	// 패널티 정보
	function clsPenalty()
	{
		this._HTMLDom = null;
		
		this._init();
	}
	
	clsPenalty.prototype = {
		_init: function(){
			var $layer = $("div#container section#main_content:eq(2) article.reserve_detail:eq(2)");
			this._HTMLDom = {
				"$layer": $layer
			}
		}
		, show: clsCourseInfo.prototype.show
		, hide: clsCourseInfo.prototype.hide
	}
	
	// 최근 예약 목록
	function clsRecentReserveList()
	{
		this._HTMLDom = null;
		this.listData = null;
		
		this._init();
	}
	
	clsRecentReserveList.prototype = {
		_init: function(){
			var $layer = $("div#container section#main_content:eq(2) article.reserve_detail:eq(3)");
			this._HTMLDom = {
				"$layer": $layer
				, "$element": $layer.find("tbody tr:first").clone(true)
			}
			
			this.setList([]);
		}
		, setList: function(thisData){
			this.listData = thisData;
			this.display();
		}
		, display: function(){
			var $layer = this._HTMLDom["$layer"];
			var $element = this._HTMLDom["$element"];
			var thisClass = this;
			
			var sValue = {
				"P": "가예약"
				, "G": "예약완료"
				, "A": "완료"
			}
			
			$layer.find("tbody").empty();
			for(var i=0;i<this.listData.length;i++){
				$layer.find("tbody").append($element.clone(true));
			}
			$layer.find("tbody tr").each(function(n){
				var d = thisClass.listData[n];
				
				$(this).find("td:eq(0)").html(d["날짜"]);
				$(this).find("td:eq(1)").html(d["시간"]);
				$(this).find("td:eq(2)").html(d["골프장명"] + " " + d["코스명"]);
				$(this).find("td:eq(3)").html(d["홀"]);
				$(this).find("td:eq(4) p:eq(0)").html(d["가격"]);
				$(this).find("td:eq(4) p:eq(1)").html(d["원가"]);
				
				$(this).find("ul.ico_list li").each(function(){
					if(d["이벤트"] != null){
						if(d["이벤트"].indexOf($(this).find("img").attr("alt")) == -1) $(this).find("img").hide();
						else $(this).find("img").show();
					}
				});
				
				$(this).find("td:eq(6)").html(sValue[d["상태코드"]] + ((d["상태코드"] == "P") ? "<br>(보증결제대기)":""));
			});
		}
		, show: clsCourseInfo.prototype.show
		, hide: clsCourseInfo.prototype.hide
		, spinStart: clsCourseInfo.prototype.spinStart
		, spinEnd: clsCourseInfo.prototype.spinEnd
	}
	
	
	// 예약정보 버튼
	function clsReserveInfoButton()
	{
		this.infoData = null;
		
		this._init();
	}
	
	clsReserveInfoButton.prototype = {
		_init: function(){
			var $layer = $("div#container section#main_content:eq(2) div.btn_area_box02");
			this._HTMLDom = {
				"$layer": $layer
			}
			
			this.setInfo({
				"예약상태": ""
				, "결제등급": ""
			});
		}
		 , setInfo:clsCourseInfo.prototype.setInfo
		 , display: function(){
		 	var $layer = this._HTMLDom["$layer"];
		 	
		 	$layer.find("img:not([alt='목록'])").hide();
		 	
		 	switch(this.infoData["예약상태"]){
		 		case "W":
		 			$layer.find("img[alt='확정예약'], img[alt='가예약']").show();
		 			break;
		 		case "P":
		 			$layer.find("img[alt='확정예약'], img[alt='가예약취소']").show();
		 			break;
		 		case "G":
		 		case "C":
		 		case "A":
		 			$layer.find("img[alt='예약취소']").show();
		 			break;
		 	}
		 	
		 	if(this.infoData["결제등급"] == "S"){
		 		$layer.find("img[alt='가예약']").hide();
		 	}
		}
		, $getLayer: function(){
			return this._HTMLDom["$layer"];
		}
	}
	
	
	// 가승인 결제 도움말
	function clsPreReserveHelpBox()
	{
		this._init();
	}
	
	clsPreReserveHelpBox.prototype = {
		_init: function(){
			var $layer = $("div#container section#main_content:eq(2)");
			this._HTMLDom = {
				"$layer": $layer
			}
		}
		, show: function(){
			this._HTMLDom["$layer"].find("div.box_txt").show(300);
		}
		, hide: function(){
			this._HTMLDom["$layer"].find("div.box_txt").hide(300);
		}
		, $getLayer: function(){
			return this._HTMLDom["$layer"];
		}
	}
	
	function clsComm()
	{
		// 지역리스트
		this.areaList = null;
		// 코스리스트
		this.courseList = null;
		
		this.courseTimeList = null;
		this.courseTimeRequest = null;
		
		// 나의 설정
		this.myConfig = null;
		
		// 웨이팅 리스트
		this.waitingTimeRequest = null;
		this.waitingTimeList = null;
		
		// 골프장 리스트
		this.golfList = null;
		this.golfRequest = null;
		
		// 예약리스트
		this.reserveRequest = null;
		this.reserveList = null;
		
		// 예약정보
		this.reserveInfo = null;
		this.reserveInfoRequest = null;
		
		// 코스정보
		this.courseInfo = null;
		//this.courseRequest = null;
		
		// 가격정보
		this.priceInfo = null;
		
		// Waiting 예약리스트
		this.waitingReserveRequest = null;
		this.waitingReserveList = null;
		
		// 최근 예약 목록
		this.recentReserveList = null;
		
		this._init();
	}
	
	clsComm.prototype = {
		_init: function(){
			// 지역리스트
			this.areaList = [];
			// 코스리스트
			this.courseList = [];
			
			this.courseTimeList = [];
			this.courseTimeRequest = {};
			
			// 나의 설정
			this.myConfig = [];
			
			// 웨이팅 리스트
			this.waitingTimeRequest = {};
			this.waitingTimeList = [];
			
			// 골프장 리스트
			this.golfList = [];
			this.golfRequest = {};
			
			// 예약리스트
			this.reserveRequest = {};
			this.reserveList = [];
			
			// 예약정보
			this.reserveInfo = {};
			this.reserveInfoRequest = {};
			
			// 코스정보
			this.courseInfo = {};
			//this.courseRequest = null;
			
			// 가격정보
			this.priceInfo = {};
			
			// Waiting 예약리스트
			this.waitingReserveRequest = {};
			this.waitingReserveList = [];
			
			// 최근 예약 목록
			this.recentReserveList = [];
		}
		, getAreaList: function(){
			var thisClass = this;
			
			this.areaList = null;
			//ajax
			document.objGlobal.getAreaCodeList({
				"콜백": function(ret, arr){
					thisClass.areaList = arr;
					
					document.objControl.finishAreaList(ret);
				}
			});
		}
		, getAreaData: function(){
			return this.areaList;
		}
		, getCourseList: function(arg){
			var thisClass = this;
			
			this.courseList = [];
			
			//ajax
			var serviceName = "reservSearchRegion";
			document.objGlobal.ajax({
				"sid": "RS001"
				, "servicename": serviceName
			}, {
				"region": arg["지역코드"]
			}, function(ret){
				var res = {
					"결과코드": ret["msp"]["contents"]["serviceResult"]
					, "메시지": document.objGlobal.getResultMsg(ret)
					, "결과값": []
				}
				
				var items = ret["msp"]["contents"]["items"];
				
				if(items){
					if(!items.length) items = new Array(items);
					
					for(var i=0;i<items.length;i++){
						var obj = items[i];
						
						res["결과값"].push({
							"코스코드": obj["course__info__id"]
							, "지역코드": obj["region"]
							, "골프장코드": obj["golfclub__id"]
							, "골프장명": obj["golfclub__name"]
							, "코스명": obj["course__info__name"]
						});
					}
				}
				
				document.objControl.finishCourseList(res);
			});
		}
		, getCourseData: function(){
			return this.courseList;
		}
		, setCourseTimeRequest: function(key, val){
			if(!this.courseTimeRequest) this.courseTimeRequest = {};
			
			this.courseTimeRequest[key] = val;
		}
		, getCourseTimeList: function(arg){
			var thisClass = this;
			
			this.courseTimeList = [];
			
			//ajax
			var serviceName = "reservSearchList";
			var szDate = this.courseTimeRequest["시작일"];
			document.objGlobal.ajax({
				"sid": "RS001"
				, "servicename": serviceName
			}, {
				"search": arg["골프장조합"]
				, "search_date": arg["시작일"]
			}, function(ret){
				var res = {
					"결과코드": ret["msp"]["contents"]["serviceResult"]
					, "메시지": document.objGlobal.getResultMsg(ret)
					, "결과값": []
				}
				
				var items = ret["msp"]["contents"]["items"];
				var aDate = arg["시작일"].split("-");
				
				var sDate = new Date(arg["시작일"].substrEx(0,4), arg["시작일"].substrEx(4,2)-1, arg["시작일"].substrEx(6,2));
				
				if(items){
					if(!items.length) items = new Array(items);
					
					for(var i=0;i<items.length;i++){
						var obj = items[i];
						
						for(j=0;j<res["결과값"].length;j++){
							var tmp1 = res["결과값"][j];
							
							if(tmp1["코스코드"] == obj["course__info__id"]+"") break;
						}
						
						if(j < res["결과값"].length){
							var tmp2 = res["결과값"][j];
							
							for(var k=0;k<tmp2["리스트"].length;k++){
								if(tmp2["리스트"][k]["예약일"] == obj["reserv__date"]+"") break;
							}
							
							if(k<tmp2["리스트"].length){
								var mor = _util.nvl(obj["mor"]);
								if(mor) mor = ("00" + mor).substrEx(-2);
								
								var aft = _util.nvl(obj["aft"]);
								if(aft) aft = ("00" + aft).substrEx(-2);
								
								tmp2["리스트"][k] = {
									"예약일": obj["reserv__date"]+""
									, "오전": _util.nvl(mor, "-")
									, "오후": _util.nvl(aft, "-")
								}
							}
						}else{
							res["결과값"].push({
								"지역코드": _util.nvl(obj["region"])
								, "골프장코드": _util.nvl(obj["golfclub__id"])
								, "코스코드": _util.nvl(obj["course__info__id"])
								, "골프장명": _util.nvl(obj["golfclub__name"])
								, "코스명": _util.nvl(obj["course__info__name"])
								, "리스트": []
							});
							
							var tmp2 = res["결과값"][res["결과값"].length-1];
							
							var newDate = new Date();
							newDate.setTime(sDate.getTime());
							for(k=0;k<document.objControl.CALENDAR_PERIOD;k++,newDate.setDate(newDate.getDate()+1)){
								var szNewDate = newDate.getFullYear() + ("00" + (newDate.getMonth()+1)).substrEx(-2) + ("00" + newDate.getDate()).substrEx(-2);
								
								if(szNewDate ==obj["reserv__date"]+""){
									var mor = _util.nvl(obj["mor"]);
									if(mor) mor = ("00" + mor).substrEx(-2);
									
									var aft = _util.nvl(obj["aft"]);
									if(aft) aft = ("00" + aft).substrEx(-2);
									
									tmp2["리스트"].push({
										"예약일": _util.nvl(obj["reserv__date"])
										, "오전": _util.nvl(mor, "-")
										, "오후": _util.nvl(aft, "-")
									});
								}else{
									tmp2["리스트"].push({
										"예약일": szNewDate
										, "오전": "-"
										, "오후": "-"
									});
								}
							}
						}
					}
				}
				document.objControl.finishCourseTimeList(res);
			});
		}
		, getCourseTimeData: function(){
			return this.courseTimeList;
		}
		// 나의 설정
		, getMyConfig: function(){
			var thisClass = this;
			
			this.myConfig = null;
			
			//ajax
			var serviceName = "reservMyOption";
			document.objGlobal.ajax({
				"sid": "RS001"
				, "servicename": serviceName
			}, {
				
			}, function(ret){
				var res = {
					"결과코드": ret["msp"]["contents"]["serviceResult"]
					, "메시지": document.objGlobal.getResultMsg(ret)
				}
				
				thisClass.myConfig = [];
				
				var items = ret["msp"]["contents"]["items"];
				
				if(items){
					if(!items.length) items = new Array(items);
					
					for(var i=0;i<items.length;i++){
						var obj = items[i];
						
						thisClass.myConfig.push({
							"지역코드": _util.nvl(obj["region"])
							, "골프장코드": _util.nvl(obj["golfclub__id"])
						});
					}
				}
				document.objControl.finishMyConfig(res);
			});
		}
		, getMyConfigData: function(){
			return this.myConfig;
		}
		, setWaitingTimeRequest: function(key, val){
			if(typeof key == "object") this.waitingTimeRequest = key;
			else this.waitingTimeRequest[key] = val;
		}
		, getWaitingTimeList: function(){
			var thisClass = this;
			
			thisClass.waitingTimeList = [];
			
			//ajax
			var serviceName = "WatingreservMainSearchList";
			var options = {
				"dateS": this.waitingTimeRequest["시작일"]
				, "search":  this.waitingTimeRequest["골프장"]
			}
			_gf.ajax({
				"sid": "WR001"
				, "servicename": serviceName
			}, options, function(ret){
				var res = {
					"결과코드": ret["msp"]["contents"]["serviceResult"]
					, "메시지": document.objGlobal.getResultMsg(ret)
				}
				
				var items = ret["msp"]["contents"]["items"];
				var aDate = options["dateS"].split("-");
				
				var sDate = new Date(options["dateS"].substrEx(0,4), options["dateS"].substrEx(4,2)-1, options["dateS"].substrEx(6,2));
				
				if(items){
					if(!items.length) items = new Array(items);
					
					for(var i=0;i<items.length;i++){
						var obj = items[i];
						
						for(j=0;j<thisClass.waitingTimeList.length;j++){
							var tmp1 = thisClass.waitingTimeList[j];
							
							if(tmp1["코스코드"] == obj["courseInfoId"]+"") break;
						}
						
						if(j < thisClass.waitingTimeList.length){
							var tmp2 = thisClass.waitingTimeList[j];
							
							for(var k=0;k<tmp2["리스트"].length;k++){
								if(tmp2["리스트"][k]["예약일"] == obj["reservDate"]+"") break;
							}
							
							if(k<tmp2["리스트"].length){
								tmp2["리스트"][k] = {
									"예약일": obj["reservDate"]+""
								}
							}
						}else{
							thisClass.waitingTimeList.push({
								"지역코드": _util.nvl(obj["region"])
								, "골프장코드": _util.nvl(obj["golfClubId"])
								, "코스코드": _util.nvl(obj["courseInfoId"])
								, "골프장명": _util.nvl(obj["golfClubNm"])
								, "코스명": _util.nvl(obj["courseInfoNm"])
								, "리스트": []
							});
							
							var tmp2 = thisClass.waitingTimeList[thisClass.waitingTimeList.length-1];
							
							var newDate = new Date();
							newDate.setTime(sDate.getTime());
							for(k=0;k<document.objControl.CALENDAR_PERIOD;k++,newDate.setDate(newDate.getDate()+1)){
								var szNewDate = newDate.getFullYear() + ("00" + (newDate.getMonth()+1)).substrEx(-2) + ("00" + newDate.getDate()).substrEx(-2);
								
								if(szNewDate ==obj["reservDate"]+""){
									tmp2["리스트"].push({
										"예약일": obj["reservDate"]+""
										, "가능여부": true
									});
								}else{
									tmp2["리스트"].push({
										"예약일": szNewDate
										, "가능여부": false
									});
								}
							}
						}
					}
				}
				document.objControl.finishWaitingTimeList(res);
			});
		}
		, getWaitingTimeData: function(){
			return this.waitingTimeList;
		}
		, setGolfRequest: function(key, val){
			if(!this.golfRequest) this.golfRequest = {};
			
			if(typeof key == "object") this.golfRequest = key;
			else this.golfRequest[key] = val;
		}
		, getGolfList: function(arg){
			var thisClass = this;
			
			//ajax
			var serviceName = "reservSearchGolfclub";
			document.objGlobal.ajax({
				"sid": "RS001"
				, "servicename": serviceName
			}, {
				"region": ""
				, "golfclub_id": ""
			}, function(ret){
				var res = {
					"결과코드": ret["msp"]["contents"]["serviceResult"]
					, "메시지": document.objGlobal.getResultMsg(ret)
					, "결과값": []
				}
				
				var items = ret["msp"]["contents"]["items"];
				if(items){
					if(!items.length) items = new Array(items);
					
					for(var i=0;i<items.length;i++){
						var obj = items[i];
						
						res["결과값"].push({
							"지역코드": obj["region"]
							, "골프장코드": obj["golfclub__id"]
							, "골프장명": obj["golfclub__name"]
						});
					}
				}
				
				document.objControl.finishGolfList(res);
			});
		}
		, getGolfData: function(){
			return this.golfList;
		}
		, setReserveRequest: function(key, val){
			if(!this.reserveRequest) this.reserveRequest = {};
			
			if(typeof key == "object") this.reserveRequest = key;
			else this.reserveRequest[key] = val;
		}
		, getReserveList: function(){
			var thisClass = this;
			
			this.reserveList = null;
			
			//ajax
			var serviceName = "reservSelectedList";
			var options = {
				"reserv_date": this.reserveRequest["날짜"]
				, "region": this.reserveRequest["지역코드"]
				, "golfclub_id": this.reserveRequest["골프장코드"]
				, "course_info_id": this.reserveRequest["코스코드"]
				, "search": this.reserveRequest["코스조합"]
			}
			document.objGlobal.ajax({
				"sid": "RS001"
				, "servicename": serviceName
				, "listcount": this.reserveRequest["갯수"]
				, "currpageno": this.reserveRequest["페이지"]
			}, options, function(ret){
				var res = {
					"결과코드": ret["msp"]["contents"]["serviceResult"]
					, "메시지": document.objGlobal.getResultMsg(ret)
				}
				
				thisClass.reserveList = [];
				
				var items = ret["msp"]["contents"]["items"];
				if(items){
					if(!items.length) items = new Array(items);
					
					for(var i=0;i<items.length;i++){
						var obj = items[i];
						var reserveTime = obj["reserv__time"]+"";
						var szEvent = "";
						
						if(obj["greenfee__use__yn"] == "Y"){
							szEvent = "그린피";
						}
						
						if(obj["cartfee__use__yn"] == "Y"){
							if(szEvent) szEvent += ",";
							szEvent += "카트피";
						}
						
						if(obj["food__use__yn"] == "Y"){
							if(szEvent) szEvent += ",";
							szEvent += "식사";
						}
						
						if(obj["present__use__yn"] == "Y"){
							if(szEvent) szEvent += ",";
							szEvent += "선물";
						}
						
						if(obj["etc__use__yn"] == "Y"){
							if(szEvent) szEvent += ",";
							szEvent += "기타";
						}
						
						thisClass.reserveList.push({
							"예약코드": _util.nvl(obj["reserv__seq"])
							, "지역코드": _util.nvl(obj["region"])
							, "골프장코드": _util.nvl(obj["golfclub__id"])
							, "골프장명": _util.nvl(obj["golfclub__name"])
							, "코스코드": _util.nvl(obj["course__info__id1"])
							, "코스명": _util.nvl(obj["course__info__name1"])
							, "예약시간": reserveTime.substrEx(0, 2) + ":" + reserveTime.substrEx(2, 2)
							, "홀명": _util.nvl(obj["hole"])
							, "가격": _util.nvl(obj["greenfee"], _util.nvl(obj["price"], 0))
							, "원가": _util.nvl(obj["price"], 0)
							, "이벤트": szEvent
							, "내상태": "미신청"
						});
					}
				}
				
				document.objControl.finishReserveList(res);
			});
		}
		, getReserveData: function(){
			return this.reserveList;
		}
		, setReserveInfoRequest: function(key, val){
			this.reserveInfoRequest = this.reserveInfoRequest || {};
			
			if(typeof key == "object") this.reserveInfoRequest = key;
			else this.reserveInfoRequest[key] = val;
		}
		, getReserveInfo: function(){
			var thisClass = this;
			
			this.reserveInfo = {};
			this.courseInfo = {};
			
			var reserveKey = this.reserveInfoRequest["예약코드"]
			
			//ajax
			var serviceName = "getReservView";
			_gf.ajax({
				"sid": "RS001"
				, "servicename": serviceName
			}, {
				"reserv_seq": reserveKey
			}, function(ret){
				var res = {
					"결과코드": ret["msp"]["contents"]["serviceResult"]
					, "메시지": document.objGlobal.getResultMsg(ret)
				}
				
				var items = ret["msp"]["contents"]["items"];
				if(items){
					var obj = items;
					
					var reserv_date = _util.nvl(obj["reserv__date"])+"";
					var reserv_time = _util.nvl(obj["reserv__time"])+"";
					var szEvent = "";
					var pDate = new Date(reserv_date.substr(0, 4), reserv_date.substr(4, 2)-1, reserv_date.substr(6, 2));
					pDate.setDate(pDate.getDate()-5);
					
					var e = [];
										
					if(obj["greenfee__use__yn"] == "Y"){
						szEvent = "그린피";
						e.push("그린피 할인: " + obj["greenfee__discount__amount"] +  obj["greenfee_amt_type"]);
					}
					
//					if(obj["mileage__use__yn"] == "Y"){
//						e.push("마일리지: " + obj["mileage__amount"] +  obj["mileage__type"]);
//					}
					
					if(obj["cartfee__use__yn"] == "Y"){
						if(szEvent) szEvent += ",";
						szEvent += "카트피";
						e.push(obj["cartfee__discount__amount"]);
					}
					
					if(obj["food__use__yn"] == "Y"){
						if(szEvent) szEvent += ",";
						szEvent += "식사";
						e.push(obj["food__discount__amount"]);
					}
					
					if(obj["present__use__yn"] == "Y"){
						if(szEvent) szEvent += ",";
						szEvent += "선물";
						e.push(obj["present__content"]);
					}
					
					if(obj["etc__use__yn"] == "Y"){
						if(szEvent) szEvent += ",";
						szEvent += "기타";
						e.push(obj["etc__content"]);
					}
					
					thisClass.reserveInfo = {
						"예약코드": reserveKey
						, "코스코드": "001"
						, "골프장명": _util.nvl(obj["golfclub__name"])
						, "코스명": _util.nvl(obj["course__info__name1"])
						, "홀명": _util.nvl(obj["hole"]) + "H"
						, "날짜": reserv_date.substr(0, 4) + ". " + reserv_date.substr(4, 2) + ". " + reserv_date.substr(6, 2)
						, "요일": _util.nvl(obj["reserve__day"])
						, "시간": reserv_time.substr(0, 2) + ":" + reserv_time.substr(2, 2)
						, "원가": _util.nvl(obj["price"], 0)
						, "가격": _util.nvl(obj["greenfee"], _util.nvl(obj["price"], 0))
						, "이벤트": szEvent
						, "보증결제금액": _util.nvl(obj["price__pay"], 0)
						, "예약상태": obj["reserv__status"]
						, "결제등급": obj["reserv__paytype"]
						, "가승인결제마감일": pDate
						, "이벤트리스트": e
					}
					
					thisClass.courseInfo = {
						"코스알림": _util.nvl(obj["course__notice"])
						, "코스명": _util.nvl(obj["course__info__name1"]) + ((obj["course__info__name2"]) ? ", " +obj["course__info__name2"]:"")
						, "상세정보": _util.nvl(obj["description"])
					}
				}
				
				document.objControl.finishReserveInfo(res);
			});
		}
		, getReserveInfoData: function(){
			return this.reserveInfo;
		}
		
		, getCourseInfoData: function(){
			return this.courseInfo;
		}
		, getPriceInfo: function(arg){
			var thisClass = this;
			
			this.priceInfo = {};
			//ajax
			var serviceName = "getGolfclubFee";
			_gf.ajax({
				"sid": "RS001"
				, "servicename": serviceName
			}, {
				"region": arg["지역코드"]
				, "golfclub_id": arg["골프장코드"]
				, "course_info_id": arg["코스코드"]
				, "resev_seq": arg["예약코드"]
			}, function(ret){
				var res = {
					"결과코드": ret["msp"]["contents"]["serviceResult"]
					, "메시지": _gf.getResultMsg(ret)
				}
				
				var items = ret["msp"]["contents"]["items"];
				if(items){
					var obj = items;
					
					thisClass.priceInfo = {
						"그린피주중회원": _util.nvl(obj["greenfee__weekday__member"], 0)
						, "그린피주말회원": _util.nvl(obj["greenfee__weekend__member"], 0)
						, "그린피주중비회원": _util.nvl(obj["greenfee__weekday__non__member"], 0)
						, "그린피주말비회원": _util.nvl(obj["greenfee__weekend__non__member"], 0)
						, "그린피주중주중회원": _util.nvl(obj["greenfee__weekday__weekdaymember"], 0)
						, "그린피주말주중회원": _util.nvl(obj["greenfee__weekend__weekdaymember"], 0)
						, "그린피기타": _util.nvl(obj["etc__price"], 0)
						, "카트비": _util.nvl(obj["cartfee"], 0)
						, "캐디비": _util.nvl(obj["caddiefee"])
						, "대여채비": _util.nvl(obj["rentfee"], 0)
						, "대여화": _util.nvl(obj["rental__shoes"], 0)
						, "코스인원제한": _util.nvl(obj["course__men__limit"])
					}
				}
				
				document.objControl.finishPriceInfo(res);
			});
		}
		, getPriceInfoData: function(){
			return this.priceInfo;
		}
		, applyReserveSubmit: function(arg){
			var thisClass = this;
			
//			arg = {
//				"예약키": null
//			}

			//ajax
			setTimeout(function(){
				var ret = {
					"처리결과": "001"
					, "메시지": null
				}
				
				document.objControl.finishApplyReserveSubmit(ret);
			}, 1000);
		}
		, setWaitingReserveRequest: function(key, val){
			if(typeof key == "object") this.waitingReserveRequest = key;
			else this.waitingReserveRequest[key] = val;
		}
		, getWaitingReserveList: function(){
			var thisClass = this;
			
			this.waitingReserveList = [];
			
			//ajax
			var serviceName = "WatingreservDetailList";
			var options = {
				"dateS": this.waitingReserveRequest["날짜"]
				, "region": this.waitingReserveRequest["지역코드"]
				, "golfClubId": this.waitingReserveRequest["골프장코드"]
				, "search": this.waitingReserveRequest["코스조합"]
				, "courseInfoId": this.waitingReserveRequest["코스코드"]
			}
			_gf.ajax({
				"sid": "WR001"
				, "servicename": serviceName
				, "listcount": this.waitingReserveRequest["갯수"]
				, "currpageno": this.waitingReserveRequest["페이지"]
			}, options, function(ret){
				var res = {
					"결과코드": ret["msp"]["contents"]["serviceResult"]
					, "메시지": document.objGlobal.getResultMsg(ret)
				}
				
				thisClass.waitingReserveList = [];
				
				var myState = {
					"": "미신청"
					, "W001": "웨이팅 중"
					, "W002": "확정예약가능"
					, "W003": "미신청"
					, "W004": "예약완료"
					, "W005": "미신청"
				}
				
				var items = ret["msp"]["contents"]["items"];
				if(items){
					if(!items.length) items = new Array(items);
					
					for(var i=0;i<items.length;i++){
						var obj = items[i];
						var reservDate = _util.nvl(obj["reservDate"])+"";
						
						thisClass.waitingReserveList.push({
							"예약코드": _util.nvl(obj["reserveSeq"])
							, "웨이팅예약코드": _util.nvl(obj["watingReservSeq"])
							, "골프장코드": _util.nvl(obj["golfClubId"])
							, "골프장명": _util.nvl(obj["golfClubNm"])
							, "코스코드": _util.nvl(obj["courseInfoId"])
							, "코스명": _util.nvl(obj["courseInfoNm"])
							, "시간대": _util.nvl(obj["reservTime"])
							, "예약시간": _util.nvl(obj["reservTimeNm"])
							, "홀명": _util.nvl(obj["holeCnt"])
							, "가격": _util.nvl(obj["maxGreenFee"], 0)
							, "원가": _util.nvl(obj["maxGreenFee"], 0)
							, "내상태코드": _util.nvl(obj["resrvStatus"])
							, "내상태": myState[_util.nvl(obj["resrvStatus"])]
							, "신청대기": _util.nvl(obj["waitCnt"], 0)
						});
					}
				}
				
				document.objControl.finishWaitingReserveList(res);
			});
		}
		, getWaitingReserveData: function(){
			return this.waitingReserveList;
		}
		// 최근 예약 목록
		, getRecentReserveList: function(){
			var thisClass = this;
			
			//ajax
			var serviceName = "getMyReservList";
			var options = {
				
			}
			_gf.ajax({
				"sid": "RS001"
				, "servicename": serviceName
			}, options, function(ret){
				var res = {
					"결과코드": ret["msp"]["contents"]["serviceResult"]
					, "메시지": document.objGlobal.getResultMsg(ret)
					, "결과값": []
				}
				
				var items = ret["msp"]["contents"]["items"];
				if(items){
					if(!items.length) items = new Array(items);
					for(var i=0;i<items.length;i++){
						var obj = items[i];
						var reserve_date = _util.nvl(obj["reserv__date"])+"";
						var reserve_time = _util.nvl(obj["reserv__time"])+"";
						
						var szEvent = "";
					
						if(obj["greenfee__use__yn"] == "Y"){
							szEvent = "그린피";
						}
						
						if(obj["cartfee__use__yn"] == "Y"){
							if(szEvent) szEvent += ",";
							szEvent += "카트피";
						}
						
						if(obj["food__use__yn"] == "Y"){
							if(szEvent) szEvent += ",";
							szEvent += "식사";
						}
						
						if(obj["present__use__yn"] == "Y"){
							if(szEvent) szEvent += ",";
							szEvent += "선물";
						}
						
						if(obj["present__use__yn"] == "Y"){
							if(szEvent) szEvent += ",";
							szEvent += "선물";
						}
						
						if(obj["etc__use__yn"] == "Y"){
							if(szEvent) szEvent += ",";
							szEvent += "기타";
						}
						
						res["결과값"].push({
							"키": _util.nvl(obj["reserv__seq"])
							, "날짜": reserve_date.substrEx(0, 4) + "." + reserve_date.substrEx(4, 2) + "." + reserve_date.substrEx(6, 2)
							, "시간": reserve_date.substrEx(0, 2) + ":" + reserve_date.substrEx(2, 2)
							, "골프장명": _util.nvl(obj["golfclub__name"])
							, "코스명": _util.nvl(obj["course__info__id1"])
							, "홀": _util.nvl(obj["hole"])
							, "가격": _util.nvl(obj["greenfee"])
							, "원가": _util.nvl(obj["price"])
							, "이벤트": szEvent
							, "상태코드": obj["reserv__status"]
						});
					}
				}
				
				document.objControl.finishRecentReserveList(res);
			});
		}
		, getRecentReserveData: function(){
			return this.recentReserveList;
		}
		// 가예약
		, preReserveSubmit: function(arg){
			var thisClass = this;
			
			//ajax
			var serviceName = "reservAccess";
			_gf.ajax({
				"sid": "RS001"
				, "servicename": serviceName
			}, {
				"reserv_seq": arg["예약코드"]
				, "reserv_status": arg["예약상태"]
				, "mid": ""
				, "merchant_key": ""
				, "moid": ""
				, "goods_name": ""
				, "card_number": ""
				, "exp_year": ""
				, "exp_month": ""
				, "card_id_no": ""
				, "card_pw": ""
			}, function(ret){
				var res = {
					"결과코드": ret["msp"]["contents"]["serviceResult"]
					, "메시지": _gf.getResultMsg(ret)
				}
				
				document.objControl.finishPreReserveSubmit(res);
			});
		}
		// 가예약취소
		, preReserveCancel: function(arg){
			var thisClass = this;
			
			//ajax
			var serviceName = "reservCancel";
			var options = {
				"reserv_seq": arg["예약코드"]
				, "reserv_status": arg["예약상태"]
			}
			_gf.ajax({
				"sid": "RS001"
				, "servicename": serviceName
			}, options,  function(ret){
				var res = {
					"결과코드": ret["msp"]["contents"]["serviceResult"]
					, "메시지": _gf.getResultMsg(ret)
				}
				
				document.objControl.finishPreReserveCancel(res);
			});
		}
		// 웨이팅 예약 신청
		, waitingApply: function(arg){
			var thisClass = this;
			
			//ajax
			var serviceName = "WatingApplySave";
			var options = {
				"reserveSeq": arg["예약코드"]
				, "golfClubId": arg["골프장코드"]
				, "courseInfoId": arg["코스코드"]
				, "reservTime": arg["예약시간"]
				, "reservDate": arg["예약일"]
			}
			_gf.ajax({
				"sid": "WR001"
				, "servicename": serviceName
			}, options, function(ret){
				var res = {
					"결과코드": ret["msp"]["contents"]["serviceResult"]
					, "메시지": _gf.getResultMsg(ret)
				}
				
				document.objControl.finishWaitingApply(res);
			});
		}
		// 웹이팅 예약 신청 취소
		, waitingApplyCancel: function(arg){
			var thisClass = this;
			
			//ajax
			var serviceName = "WatingApplyCancel";
			var options = {
				"watingReservSeq": arg["예약코드"]
			}
			_gf.ajax({
				"sid": "WR001"
				, "servicename": serviceName
			}, options, function(ret){
				var res = {
					"결과코드": ret["msp"]["contents"]["serviceResult"]
					, "메시지": _gf.getResultMsg(ret)
				}
				
				document.objControl.finishWaitingApplyCancel(res);
			});
		}
	}
	
	// 컨트롤
	function clsControl()
	{
		this.objComm = null;
		this.objLeftReserveType = null;
		//this.objBodyReserveType = null;
		this.objCalendar = null;
		this.objAreaGolfList = null;
		this.objMyConfig = null;
		this.objMyReserveListConfirm = null;
		this.objWeekCalendar = null;
		this.objCourseTimeList = null;
		this.objAreaList = null;
		this.objWeekCalendar2 = null;
		this.objCourseList = null;
		this.objReserveList = null;
		this.objReserveInfoTab = null;
		this.objReserveInfo = null;
		this.objCourseInfo = null;
		this.objAbstractReserveInfo = null;
		this.objPriceInfo = null;
		this.objPanelty = null;
		this.objRecentReserveList = null;
		this.objReserveInfoButton = null;
		this.objPreReserveHelpBox = null;
		
		this.courseKey = null;
		this.colNum = null;
		
		this.CALENDAR_PERIOD = 14;
		
		this._permitStart = null;
	}
	
	clsControl.prototype = {
		_init: function(){
			this._preload();
			
			
			
			this.objComm = new clsComm();
			this.objLeftReserveType = new clsLeftReserveType();
			//this.objBodyReserveType = new clsBodyReserveType();
			this.objCalendar = new clsCalendar();
			this.objAreaGolfList = new clsAreaGolfList();
			this.objMyConfig = new clsMyConfig();
			this.objMyReserveListConfirm = new clsMyReserveListConfirm();
			this.objWeekCalendar = new clsWeekCalendar();
			this.objCourseTimeList = new clsCourseTimeList();
			this.objAreaList = new clsAreaList();
			this.objWeekCalendar2 = new clsWeekCalendar2();
			this.objCourseList = new clsCourseList();
			this.objReserveList = new clsReserveList();
			this.objReserveInfoTab = new clsReserveInfoTab();
			this.objReserveInfo = new clsReserveInfo();
			this.objCourseInfo = new clsCourseInfo();
			this.objAbstractReserveInfo = new clsAbstractReserveInfo();
			this.objPriceInfo = new clsPriceInfo();
			this.objPenalty = new clsPenalty();
			this.objRecentReserveList = new clsRecentReserveList();
			this.objReserveInfoButton = new clsReserveInfoButton();
			this.objPreReserveHelpBox = new clsPreReserveHelpBox();
			
			this._beforeStart();
			this._bind();
		}
		, _preload: function(){
			// 코스별 예약리스트 레이어 불러오기
			$.ajax({
				url: "reserve_list.html"
				, type: "get"
				, dataType: "html"
				, async: false
				, success: function(ret, sta){
					var szInject = "";
					var sectionStartIndex = ret.indexOf('<section id="main_content');
					var sectionEndIndex = ret.indexOf("</section", sectionStartIndex);
					
					szInject = ret.substring(sectionStartIndex, sectionEndIndex) + "</section>";
					
					$("div#container").append(szInject);
				}
				, error: function(){
					
				}
			});
			
			// 예약타임 상세정보 불러오기
			$.ajax({
				url: "reserve_view.html"
				, type: "get"
				, dataType: "html"
				, async: false
				, success: function(ret, sta){
					var szInject = "";
					var sectionStartIndex = ret.indexOf('<section id="main_content');
					var sectionEndIndex = ret.indexOf("</section", sectionStartIndex);
					
					szInject = ret.substring(sectionStartIndex, sectionEndIndex) + "</section>";
					
					$("div#container").append(szInject);
				}
				, error: function(){
					
				}
			});
			
			
			
			// 가예약완료 불러오기
			$.ajax({
				url: "reserve_check.html"
				, type: "get"
				, dataType: "html"
				, async: false
				, success: function(ret, sta){
					var szInject = "";
					var sectionStartIndex = ret.indexOf('<section id="main_content');
					var sectionEndIndex = ret.indexOf("</section", sectionStartIndex);
					
					szInject = ret.substring(sectionStartIndex, sectionEndIndex) + "</section>";
					
					$("div#container").append(szInject);
				}
				, error: function(){
					
				}
			});
			
			// 예약완료 불러오기
			$.ajax({
				url: "reserve_ok.html"
				, type: "get"
				, dataType: "html"
				, async: false
				, success: function(ret, sta){
					var szInject = "";
					var sectionStartIndex = ret.indexOf('<section id="main_content');
					var sectionEndIndex = ret.indexOf("</section", sectionStartIndex);
					
					szInject = ret.substring(sectionStartIndex, sectionEndIndex) + "</section>";
					
					$("div#container").append(szInject);
				}
				, error: function(){
					
				}
			});
			
			
			// 웨이팅예약 불러오기
			$.ajax({
				url: "waiting_list.html"
				, type: "get"
				, dataType: "html"
				, async: false
				, success: function(ret, sta){
					var szInject = "";
					var sectionStartIndex = ret.indexOf('<section id="main_content');
					var sectionEndIndex = ret.indexOf("</section", sectionStartIndex);
					
					szInject = ret.substring(sectionStartIndex, sectionEndIndex) + "</section>";
					
					$("div#container").append(szInject);
				}
				, error: function(){
					
				}
			});
			
			// 웨이팅예약 세팅
			$("div#container section#main_content:eq(1)").append($("div#container section#main_content:eq(5) article.reserve_list"));
		}
		, _beforeStart: function(){
			var thisClass = this;
			
			this._permitStart = {
				"지역정보": false
				, "골프장정보": false
				, "나의설정": false
			}
			
			_gf.spinStart();
			
			$("div.box_txt").hide();
			
			// 지역정보
			this.objAreaGolfList.spinStart();
			this.objComm.getAreaList();
			
			_util.executeThread(function(){
				for(var key in thisClass._permitStart){
					if(!thisClass._permitStart[key]) return false;
				}
				
				return true;
			}, function(){
				_gf.spinEnd();
				thisClass._start();
			});
			
			
		}
		, _start: function(){
			var q_type = _util.getParam("q_type");
			
			if(q_type){
				this.objLeftReserveType.setIdx(q_type-0);
			}
			
			// 최근예약목록
			this.objComm.getRecentReserveList();
			
			// 기본날짜 설정
			var tomorow = new Date();
			tomorow.setHours(0);
			tomorow.setMinutes(0);
			tomorow.setSeconds(0);
			tomorow.setMilliseconds(0);
			tomorow.setDate(tomorow.getDate()+1);
			
			var cDate = new Date();
			cDate.setTime(tomorow.getTime());
			
			this.objCalendar.setInfo("달력일", cDate);
			this.objCalendar.setInfo("시작일", tomorow);
			
			this.setCalendarDate();
		}
		, _bind: function(){
			var thisClass = this;
			
			// 예약분류 선택
			this.objLeftReserveType.$getLayer().on("change", "select", function(){
				var n = thisClass.objLeftReserveType.getIdx();
				
				if(n == 2){
					document.location.href = "event_list.html";
					return;
				}
			});
			
			// 달력의 날짜 클릭
			this.objCalendar.$getBtnCalendar().live("click", function(){
				thisClass.setCalendarDate($(this).data("날짜"));
			});
			
			// 달력 이전월
			this.objCalendar.$getBtnPrev().click(function(){
				thisClass.objCalendar.prevMonth();
			});
			
			// 달력 이후월
			this.objCalendar.$getBtnNext().click(function(){
				thisClass.objCalendar.nextMonth();
			});
			
			// 좌측 지역선택 체크박스
			this.objAreaGolfList.$getCheckBoxs().live("click", function(){
				thisClass.objAreaGolfList.onCheck($(this));
			});
			
			// my설정
			$("span img[alt='my설정']").click(function(){
				var winMyArea = window.open("../popup/pop_fix.html", "winMyArea", "width=600, height=100, scrollbars=0");
				if(winMyArea) winMyArea.focus();
			});
			
			// 검색
			$("div#container section#left_content img[alt='전체 현황검색']").click(function(){
				thisClass.reserveSearch();
			});
			
			// 목록
			$("div#container section#main_content img[alt='목록']").click(function(){
				thisClass.reserve_list();
			});
			
			// 나의 예약내역 확인
			this.objMyReserveListConfirm.$getBtn().click(function(){
				var winMyReserveList = window.open(_ROOT + "/popup/pop_myreserve.html", "winMyReserveList", "width=640, height=320, scrollbars=0");
				if(winMyReserveList) winMyReserveList.focus();
			});
			
			this._date_reserve_bind();
			this._reserve_list_bind();
			this._reserve_info_bind();
			//this._reserve_confirm_bind();
		}
		, _date_reserve_bind: function(){
			var thisClass = this;
			
			// 도움말 토글
			this.objMyConfig.$getBtnHelp().bind("mouseenter mouseleave", function(){
				thisClass.objMyConfig.toggle();
			});
			
			// 주력 이전
			this.objWeekCalendar.$getBtnPrev().click(function(){
				var newDate = thisClass.objWeekCalendar.getDate();
				newDate.setDate(newDate.getDate()-thisClass.CALENDAR_PERIOD);
				
				thisClass.objWeekCalendar.setDate(newDate);
				thisClass.objCalendar.setInfo("시작일", newDate);
				
				thisClass.reserveSearch();
			});
			
			// 주력 이후
			this.objWeekCalendar.$getBtnNext().click(function(){
				var newDate = thisClass.objWeekCalendar.getDate();
				newDate.setDate(newDate.getDate()+thisClass.CALENDAR_PERIOD);
				
				thisClass.objWeekCalendar.setDate(newDate);
				thisClass.objCalendar.setInfo("시작일", newDate);
				
				thisClass.reserveSearch();
			});
			
			// 주력 날짜 선택
			this.objWeekCalendar.$getDateBox().click(function(){
				var idx = thisClass.objWeekCalendar.$getDateBox().index($(this));
				if(idx < 0) idx = thisClass.objWeekCalendar2.$getDateBox().index($(this));
				
				var newDate = new Date();
				newDate.setTime(thisClass.objWeekCalendar.getDate().getTime());
				newDate.setDate(newDate.getDate() + idx);
				
				thisClass.objWeekCalendar.setSelDate(newDate);
				
				
				var reserveTypeIdx = thisClass.objLeftReserveType.getIdx();
				
				switch(reserveTypeIdx){
					case 0:
						thisClass.reserve_list();
						break;
					case 1:
						thisClass.waiting_list();
						break;
				}
			});
			
			// 코스별리스트 클릭
			this.objCourseTimeList.$getBtns().live("click", function(){
				var n = thisClass.objCourseTimeList.$getBtns().index($(this));
				var rowNum = Math.floor(n / thisClass.CALENDAR_PERIOD);
				var colNum = n % thisClass.CALENDAR_PERIOD;
				var courseKey = thisClass.objCourseTimeList.getCourseKey(rowNum);
				var areaKey = thisClass.objCourseTimeList.getAreaKey(rowNum);
				
				thisClass.courseKey = courseKey;
				thisClass.colNum = colNum;
				
				thisClass.objAreaList.setKey(areaKey);
				thisClass.objAreaList.$getSelect().trigger("change");
				// 골프장 리스트 요청
				//thisClass.fnGolfListRequest();
				//thisClass.objWeekCalendar.$getDateBox().eq(colNum).trigger("click");
			});
		}
		, _reserve_list_bind: function(){
			var thisClass = this;
			
			// 지역선택
			this.objAreaList.$getSelect().change(function(){
				//thisClass.objAreaList.setIdx(thisClass.objAreaList.$getBtns().index($(this)));
				
				// 골프장 리스트 요청
				thisClass.fnGolfListRequest();
			});
			
			// 주력 출력후 2번째 2주력 출력
			$(this.objWeekCalendar).bind("evtFinishDisplay", function(){
				var $obj = arguments[1];
				var sDate = thisClass.objWeekCalendar.getDate();
				
				thisClass.objWeekCalendar2.display($obj, sDate.getMonth()+1);
			});
			
			// 골프장 선택
			/*this.objGolfList.$getSelect().change(function(){
				thisClass.objGolfList.setIdx(thisClass.objGolfList.$getBtns().index($(this)));
				
				//thisClass.reserve_list();
			});*/
			
			
			// 예약 리스트 정렬 선택
			this.objReserveList.$getBtnOrder().css("cursor", "pointer").click(function(){
				var idx = thisClass.objReserveList.$getBtnOrder().index($(this));
				thisClass.objReserveList.setOrder(idx);
				
				thisClass.reserve_list();
			});
			
			// 예약리스트 상세보기
			/*this.objReserveList.$getBtnCourses().live("click", function(){
				thisClass.objReserveList.setIdx(thisClass.objReserveList.$getBtnCourses(true).index($(this)));
				//var winAuthCerify = window.open("../popup/pop_certify.html?q_type=info", "winAuthCerify", "width=400, height=340, scrollbars=0");
				//if(winAuthCerify) winAuthCerify.focus();
				thisClass.reserve_info();
			});*/
			
			// 예약리스트 예약하기
			this.objReserveList.$getBtnApplys().live("click", function(){
				var n = thisClass.objReserveList.$getBtnApplys().index($(this));
				
				thisClass.objReserveList.setIdx(n);
				//var winAuthCerify = window.open("../popup/pop_certify.html?q_type=apply", "winAuthCerify", "width=400, height=340, scrollbars=0");
				//if(winAuthCerify) winAuthCerify.focus();
				
				//thisClass.reserve_confirm();
				thisClass.reserve_info();
			});
			
			// 검색
			$("div#container section#main_content:eq(1) a").has("img[alt='검색']").click(function(){
				//var reserveTypeIdx = thisClass.objBodyReserveType.getIdx();
				var reserveTypeIdx = thisClass.objLeftReserveType.getIdx();
				
				//thisClass.objLeftReserveType.setIdx(reserveTypeIdx);
				
				switch(reserveTypeIdx){
					case 0:
						thisClass.reserve_list();
						break;
					case 1:
						thisClass.waiting_list();
						break;
				}
				
				
			});
			
			
			
			// 웨이팅신청
			this.objReserveList.$getLayer().on("click", "img[alt='웨이팅신청'], img[alt='신청취소']", function(){
				var bName = $(this).attr("alt");
				
				var n = thisClass.objReserveList.$getLayer().find("img[alt='" + bName + "']").index($(this));
				thisClass.objReserveList.setIdx(n);
				
				switch(bName){
					case "웨이팅신청":
						//thisClass.getWaitingReserveInfo();
						var winWaitingReserve = window.open(_ROOT + "/popup/pop_waiting_app.html", "winWaitingReserve", "width=400, height=400, scrollbars=0");
						if(winWaitingReserve) winWaitingReserve.focus();
						break;
					case "신청취소":
						if(!confirm("웨이팅을 취소하시겠습니까?"))return;
						thisClass.objComm.waitingApplyCancel({
							"예약코드": thisClass.objReserveList.getKey()
						});
						break;
				}
			});
		}
		, _reserve_info_bind: function(){
			var thisClass = this;
			
			// 예약하기
//			$("div#container section#main_content:eq(2) img[alt='예약신청']").click(function(){
//				thisClass.reserve_confirm();
//			});
			
			// 탭
			this.objReserveInfoTab.$getLayer().on("click", "li", function(){
				var n = thisClass.objReserveInfoTab.$getLayer().find("li").index($(this));
				
				thisClass.objReserveInfoTab.setIdx(n);
				thisClass.reserve_info_tab();
			});
			
			// 목록
			this.objReserveInfoButton.$getLayer().on("click", "img[alt='목록']", function(){
				$("div#container section#main_content:eq(1) a").has("img[alt='검색']").trigger("click");
			});
			
			// 가예약
			this.objReserveInfoButton.$getLayer().on("click", "img[alt='가예약'], img[alt='가예약취소']", function(){
				var reserveInfo = thisClass.objComm.getReserveInfoData();
				var bName = $(this).attr("alt");
				
				switch(bName){
					case "가예약": 
						thisClass.objComm.preReserveSubmit({
							"예약코드": reserveInfo["예약코드"]
							, "예약상태": "P"
						});
						break;
					case "가예약취소":
						if(!confirm("가예약을 취소하시겠습니까?\n[확인]을 누르시면 예약이 취소됩니다.")) return;
						thisClass.objComm.preReserveCancel({
							"예약코드": reserveInfo["예약코드"]
							, "예약상태": "P"
						});
						break;
				}
			});
			
			// 가예약 도움말
			this.objPreReserveHelpBox.$getLayer().on("mouseenter mouseout", "p.reserve_q a", function(event){
				switch(event.type){
					case "mouseenter":
						thisClass.objPreReserveHelpBox.show();
						break;
					case "mouseout":
						thisClass.objPreReserveHelpBox.hide();
						break;
					
				}
			});
			
			// 실시간 예약 검색 홈으로
			this.objAbstractReserveInfo.$getLayer().on("click", "img[alt='실시간 예약 홈으로']", function(){
				thisClass.date_reserve();
			});
		}
//		, _reserve_confirm_bind: function(){
//			var thisClass = this;
//			
//			// 가예약하기
//			$("div#container section#main_content:eq(3) img[alt='가예약']").click(function(){
//				alert("가예약 안대요");
//			});
//			
//			// 보증결제 예약하기
//			$("div#container section#main_content:eq(3) img[alt='예약(보증결제) 하기']").click(function(){
//				alert("예약(보증결제) 하기 안대요");
//			});
//		}
		// 검색
		, reserveSearch: function(){
			var reserveTypeIdx = this.objLeftReserveType.getIdx();
			
			//this.objBodyReserveType.setIdx(reserveTypeIdx);
				
			switch(reserveTypeIdx){
				case 0:
					this.date_reserve();
					break;
				case 1:
					this.date_waiting();
					//this.waiting_list();
					break;
				case 2:
					this.event_list();
					break;
			}
		}
		// 달력선택
		, setCalendarDate: function(objDate){
			if(objDate) this.objCalendar.setInfo("시작일", objDate);
			var newDate = this.objCalendar.getSDate();
				
			//주력에 전달
			this.objWeekCalendar.setDate(newDate);
			
			// 검색
			//this.date_reserve();
			this.reserveSearch();
		}
		// 지역정보 완료
		, finishAreaList: function(ret){
			if(ret["메시지"]) alert(ret["메시지"]);
			if(ret["결과코드"] != "00000") return;
			
			var thisData = this.objComm.getAreaData();
			
			// 코스정보 요청
			this.objComm.getGolfList();
			
			// 좌측 지역선택 출력
			var areaClone1 = document.objUtil.objectCopy(thisData);
			this.objAreaGolfList.setAreaList(areaClone1);
			
			// 리스트 출력
			var areaClone2 = document.objUtil.objectCopy(thisData);
			this.objCourseTimeList.setList(areaClone2);
			
			// 본문 지역선택
			var areaClone3 = document.objUtil.objectCopy(thisData);
			this.objAreaList.setList(areaClone3);
			
			this._permitStart["지역정보"] = true;
		}
		// 골프장 리스트 완료
		, finishGolfList: function(ret){
			if(ret["메시지"]) alert(ret["메시지"]);
			if(ret["결과코드"] != "00000") return;
			
			this.objAreaGolfList.spinEnd();
			this.objAreaGolfList.setGolfList(ret["결과값"]);
			
			// 나의 설정 요청
			this.objComm.getMyConfig();
			
			this._permitStart["골프장정보"] = true;
		}
		// 코스정보 완료
		, finishCourseList: function(ret){
			if(ret["메시지"]) alert(ret["메시지"]);
			if(ret["결과코드"] != "00000") return;
			
			var thisData = this.objComm.getGolfData();
				
			this.objCourseList.setList(ret["결과값"]);
			if(this.courseKey){
				this.objCourseList.setCourseKey(this.courseKey);
				this.objWeekCalendar.$getDateBox().eq(this.colNum).trigger("click");
				
				this.courseKey = null;
				this.colNum = null;
			}
		}
		// my설정 완료
		, closeMySetting: function(w){
			if(w) w.close();
			document.location.reload();
		}
		// 코스리스트 완료
		, finishCourseTimeList: function(ret){
			if(ret["메시지"]) alert(ret["메시지"]);
			if(ret["결과코드"] != "00000") return;
			
			//var thisData = this.objComm.getCourseTimeData();
			
			this.objCourseTimeList.spinEnd();
			
			this.objCourseTimeList.setCourseList(ret["결과값"]);
		}
		// 웨이팅 리스트완료
		, finishWaitingTimeList: function(ret){
			if(ret["메시지"]) alert(ret["메시지"]);
			if(ret["결과코드"] != "00000") return;
			
			var thisData = this.objComm.getWaitingTimeData();
			
			this.objCourseTimeList.spinEnd();

			this.objCourseTimeList.setCourseList(thisData);
		}
		// 날짜별 코스리스트
		, date_reserve: function(){
			var thisClass = this;
			
			$("div#container section[id=main_content]").hide();
			
			$("div#container section#main_content:eq(0)").show();
			
			// 특정일 예약 리스트 초기화
			this.objAreaList.setIdx(0);
			this.objAreaList.$getSelect().trigger("change");
			//this.objAreaList.$getBtns().eq(0).trigger("click");
			
			this.objCourseTimeList.setSatIndexs(this.objWeekCalendar.getSatIndexs());
			this.objCourseTimeList.setSunIndexs(this.objWeekCalendar.getSunIndexs());
			
			this.objCourseTimeList.setListType("실시간");
			this.objCourseTimeList.spinStart();
			
			document.objUtil.executeThread(function(){
				var areaCodeList = thisClass.objComm.getAreaData();
				var myConfig = thisClass.objComm.getMyConfigData();
				
				return areaCodeList && myConfig;
			}, function(){
				var szGolf = thisClass.objAreaGolfList.getValue();
				var sDate = thisClass.objCalendar.getSDate();
				
//				thisClass.objComm.setCourseTimeRequest("코스", szCourse);
//				thisClass.objComm.setCourseTimeRequest("시작일", sDate.getFullYear() + ("00" + (sDate.getMonth()+1)).substrEx(-2) + ("00" + sDate.getDate()).substrEx(-2));
				
				thisClass.objComm.getCourseTimeList({
					"골프장조합": szGolf
					, "시작일": sDate.getFullYear() + ("00" + (sDate.getMonth()+1)).substrEx(-2) + ("00" + sDate.getDate()).substrEx(-2)
				});
			});
		}
		// 날짜별 웨이팅리스트
		, date_waiting: function(){
			var thisClass = this;
			
			$("div#container section[id=main_content]").hide();
			
			$("div#container section#main_content:eq(0)").show();
			
			// 특정일 예약 리스트 초기화
			this.objAreaList.setIdx(0);
			this.objAreaList.$getSelect().trigger("change");
			//this.objAreaList.$getBtns().eq(0).trigger("click");
			
			var szCourse = this.objAreaGolfList.getValue();
			var sDate = this.objCalendar.getSDate();
			
			this.objCourseTimeList.setSatIndexs(this.objWeekCalendar.getSatIndexs());
			this.objCourseTimeList.setSunIndexs(this.objWeekCalendar.getSunIndexs());
			
			this.objComm.setCourseTimeRequest("코스키", szCourse);
			this.objComm.setCourseTimeRequest("시작일", sDate.getFullYear() + "-" + (sDate.getMonth()+1) + "-" + sDate.getDate());
			
			this.objCourseTimeList.setListType("웨이팅");
			this.objCourseTimeList.spinStart();
			
			document.objUtil.executeThread(function(){
				var areaCodeList = thisClass.objComm.getAreaData();
				var myConfig = thisClass.objComm.getMyConfigData();
				
				return areaCodeList && myConfig;
			}, function(){
				var szGolf = thisClass.objAreaGolfList.getValue();
				var sDate = thisClass.objCalendar.getSDate();
				
				thisClass.objComm.setWaitingTimeRequest({
					"골프장": szGolf
					, "시작일": sDate.getFullYear() + ("00" + (sDate.getMonth()+1)).substrEx(-2) + ("00" + sDate.getDate()).substrEx(-2)
				});
				thisClass.objComm.getWaitingTimeList();
			});
		}
		// 특정일 예약리스트
		, reserve_list: function(){
			$("div#container section[id=main_content]").hide();
			
			$("div#container section#main_content:eq(1)").show();
			
			var selDate = this.objWeekCalendar.getSelDate();
			
			this.objComm.setReserveRequest({
				"지역코드": this.objAreaList.getValue()
				, "골프장코드": this.objCourseList.getGolfKey()
				, "코스코드": this.objCourseList.getCourseKey()
				, "코스조합": this.objAreaGolfList.getValue()
				, "날짜": selDate.getFullYear() + ("00" + (selDate.getMonth()+1)).substrEx(-2) + ("00" + selDate.getDate()).substrEx(-2)
				, "갯수": 10000
				, "페이지": 1
				, "정렬": this.objReserveList.getOrder()
			});
			
			this.objReserveList.spinStart();
			this.objComm.getReserveList();
		}
		// 웨이팅예약
		, waiting_list: function(){
			$("div#container section[id=main_content]").hide();
			
			$("div#container section#main_content:eq(1)").show();
			
			var selDate = this.objWeekCalendar.getSelDate();
			
			if(!selDate){
				this.objWeekCalendar.$getDateBox().eq(0).trigger("click");
				return;
			}
			
			this.objComm.setWaitingReserveRequest({
				"지역코드": this.objAreaList.getValue()
				, "골프장코드": this.objCourseList.getGolfKey()
				, "코스코드": this.objCourseList.getCourseKey()
				, "코스조합": this.objAreaGolfList.getValue()
				, "날짜": selDate.getFullYear() + ("00" + (selDate.getMonth()+1)).substrEx(-2) + ("00" + selDate.getDate()).substrEx(-2)
				, "갯수": 10000
				, "페이지": 1
				, "정렬": this.objReserveList.getOrder()
			});

			this.objReserveList.spinStart();
			this.objComm.getWaitingReserveList();
		}
		// 특정예약정보
		, reserve_info: function(){
			$("div#container section[id=main_content]").hide();
			
			$("div#container section#main_content:eq(2)").show();
			
			var reserveKey = this.objReserveList.getKey();
			var areaKey = this.objReserveList.getAreaKey();
			var golfKey = this.objReserveList.getGolfKey();
			var courseKey = this.objReserveList.getCourseKey();
			
			if(!(reserveKey && areaKey && golfKey && courseKey)) return;
			
			this.objReserveInfo.spinStart();
			this.objComm.setReserveInfoRequest("예약코드", reserveKey);
			this.objComm.getReserveInfo();
			
			this.objComm.getPriceInfo({
				"예약코드": reserveKey
				, "지역코드": areaKey
				, "골프장코드": golfKey
				, "코스코드": courseKey
			});
			
			/*this.objCourseInfo.spinStart();
			this.objComm.setCourseRequest("코스코드", courseKey);
			this.objComm.getCourseInfo();*/
		}
		// 예약확인
		/*, reserve_confirm: function(){
			$("div#container section[id=main_content]").hide();
			
			$("div#container section#main_content:eq(3)").show();
			
			var reserveKey = this.objReserveList.getKey();
			var courseKey = this.objReserveList.getCourseKey();
			
			if(!(courseKey && reserveKey)) return;
			
			this.objAbstractReserveInfo.spinStart();
			this.objComm.setReserveInfoRequest("예약키", reserveKey);
			this.objComm.getReserveInfo();
			
			this.objRecentReserveList.spinStart();
			this.objComm.getRecentReserveList();
		}*/
		// 예약완료
		, reserve_finish: function(){
			$("div#container section[id=main_content]").hide();
			
			$("div#container section#main_content:eq(4)").show();
		}
		// 예약정보 내 탭 분류
		, reserve_info_tab: function(){
			var idx = this.objReserveInfoTab.getIdx();
			var aList = [
				this.objCourseInfo
				, this.objPriceInfo
				, this.objPenalty
				, this.objRecentReserveList
			];
			
			for(var i=0;i<aList.length;i++){
				if(i == idx) aList[i].show();
				else aList[i].hide();
			}
		}
		// 골프장 리스트 요청
		, fnGolfListRequest: function(){
			this.objCourseList.reset();
			var areaKey = this.objAreaList.getValue();
			
			if(!areaKey) return;
			
			// 골프장 리스트 요청
			//this.objComm.setGolfRequest("지역코드", areaKey);
			this.objComm.getCourseList({
				"지역코드": areaKey
			});
			
			//this.reserve_list();
		}
		// 예약리스트 완료
		, finishReserveList: function(ret){
			if(ret["메시지"]) alert(ret["메시지"]);
			if(ret["결과코드"] != "00000") return;
			
			var thisData = this.objComm.getReserveData();
				
			this.objReserveList.spinEnd();
			
			this.objReserveList.setType(0);
			this.objReserveList.setList(thisData);
		}
		// Waiting 예약리스트 완료
		, finishWaitingReserveList: function(ret){
			if(ret["메시지"]) alert(ret["메시지"]);
			if(ret["결과코드"] != "00000") return;
			
			var thisData = this.objComm.getWaitingReserveData();
				
			this.objReserveList.spinEnd();
			this.objReserveList.setType(1);
			this.objReserveList.setList(thisData);
		}
		// 예약정보 완료
		, finishReserveInfo: function(){
			var thisData = this.objComm.getReserveInfoData();
				
			this.objReserveInfo.spinEnd();
			this.objAbstractReserveInfo.spinEnd();
			
			this.objReserveInfo.setInfo(thisData);
			this.objAbstractReserveInfo.setLayer(this.objReserveInfo.clone());
			
			this.objReserveInfoButton.setInfo({
				"결제등급": thisData["결제등급"]
				, "예약상태": thisData["예약상태"]
			});
			
			var courseData = this.objComm.getCourseInfoData();
				
			this.objCourseInfo.spinEnd();
			this.objCourseInfo.setInfo(courseData);
			
			this.objReserveInfoTab.setIdx(0);
			this.reserve_info_tab();
		}
		// 가격정보 완료
		, finishPriceInfo: function(ret){
			var thisData = this.objComm.getPriceInfoData();
			
			this.objPriceInfo.setInfo(thisData);
		}
		// 예약완료
		, reserve_ok: function(){
			var reserveKey = this.objReserveList.getKey();
			
			if(!reserveKey) return;
			
			this.reserve_info();
		}
		// 인증완료 후
		, certified: function(w, actionType, reserveKey){
			w.close();
			
			this.objReserveList.setKey(reserveKey);
			switch(actionType){
				case "info":
					this.reserve_info();
					break;
				case "apply":
					var winApplyReserve = window.open("../popup/pop_offer.html", "winApplyReserve", "width=400, height=300, scrollbars=0");
					if(winApplyReserve) winApplyReserve.focus();
					break;
			}
		}
		// 예약키 전달
		, getReserveKey: function(){
			return this.objReserveList.getKey();
		}
		// 코스정보 완료
		, finishCourseInfo: function(){
			var thisData = this.objComm.getCourseInfoData();
				
			this.objCourseInfo.spinEnd();
			this.objCourseInfo.setInfo(thisData);
		}
		// 예약하기
//		, applyReserve: function(w, reserveKey){
//			w.close();
//			
//			this.reserve_confirm();
//			
//			// 예약
//			/*document.objGlobal.spinStart("sending...");
//			this.objReserveList.setKey(reserveKey);
//			this.objComm.applyReserveSubmit({
//				"예약키": reserveKey
//			});*/
//		}
		// 예약완료
		, finishApplyReserveSubmit: function(){
			var ret = arguments[1];
			
			document.objGlobal.spinEnd();
			this.reserve_ok();
		}
		// 최근 예약 목록 완료
		, finishRecentReserveList: function(ret){
			if(ret["메시지"]) alert(ret["메시지"]);
			if(ret["결과코드"] != "00000") return;
			
			this.objMyReserveListConfirm.setInfo(ret["결과값"].length);
			
			this.objRecentReserveList.spinEnd();
			this.objRecentReserveList.setList(ret["결과값"]);
		}
		// 나의 설정 완료
		, finishMyConfig: function(ret){
			if(ret["메시지"]) alert(ret["메시지"]);
			if(ret["결과코드"] != "00000") return;
			
			var thisData = this.objComm.getMyConfigData();
			
			this.objAreaGolfList.setMyConfig(thisData);
			
			this._permitStart["나의설정"] = true;
		}
		// 관심지역 레이어 dl
		, $getCourseListLayer: function(){
			return this.objAreaGolfList.$getLayer().clone(true);
		}
		// 나의 설정
		, getMyConfigData: function(){
			return this.objComm.getMyConfigData();
		}
		// 가예약완료
		, finishPreReserveSubmit: function(ret){
			if(ret["메시지"]) alert(ret["메시지"]);
			if(ret["결과코드"] != "00000") return;
			
			$("div#container section[id=main_content]").hide();
			
			$("div#container section#main_content:eq(3)").show();
			
			var pDate = this.objReserveInfo.getPDate();
			this.objAbstractReserveInfo.setPDate(pDate);
		}
		// 가예약취소 완료
		, finishPreReserveCancel: function(ret){
			if(ret["메시지"]) alert(ret["메시지"]);
			if(ret["결과코드"] != "00000") return;
			
			this.reserve_info();
		}
		// 웨이팅 신청 완료
		, finishWaitingApply: function(ret){
			if(ret["메시지"]) alert(ret["메시지"]);
			if(ret["결과코드"] != "00000") return;
			
			this.waiting_list();
		}
		// 웨이팅 신청취소 완료
		, finishWaitingApplyCancel: function(ret){
			if(ret["메시지"]) alert(ret["메시지"]);
			if(ret["결과코드"] != "00000") return;
			
			this.waiting_list();
		}
		// 웨이팅 신청 팝업에서 요청하는 웨이팅 정보
		, getWaitingReserveInfo: function(){
			var reserveKey = this.objReserveList.getKey();
			var golfKey = this.objReserveList.getGolfKey();
			var golfName = this.objReserveList.getGolfName();
			var courseKey = this.objReserveList.getCourseKey();
			var courseName = this.objReserveList.getCourseName();
			var selDate = this.objWeekCalendar.getSelDate();
			var weekDay = ["일", "월", "화", "수", "목", "금", "토"];
			var szTime = this.objReserveList.getReserveTime();
			
			var szNote = selDate.getFullYear() + "년 " + ("00" + (selDate.getMonth()+1)).substrEx(-2) + "월 " + ("00" + selDate.getDate()).substrEx(-2) + "일(" + weekDay[selDate.getDay()] + ")<br>" + golfName + " " + courseName + " " + szTime + "<br>";
			var reserveInfo = {
				"예약코드": reserveKey
				, "골프장코드": golfKey
				, "코스코드": courseKey
				, "예약시간": szTime
				, "예약일": selDate.getFullYear() + ("00" + (selDate.getMonth()+1)).substrEx(-2) + ("00" + selDate.getDate()).substrEx(-2)
			}
			
			var ret = {
				"예약코드": reserveKey
				, "내용": szNote
				, "예약정보": reserveInfo
			}
			
			return ret;
		}
		// 웨이팅 신청하기
		, closeWaitingApply: function(w, reserveInfo){
			if(w) w.close();
			
			this.objComm.waitingApply(reserveInfo);
		}
	}
	
	document.objControl = new clsControl();
	document.objControl._init();
});
